Closed wizardbyron closed 5 years ago
直接在一个docker容器里面,按操作步骤执行,报错了:
root@dcaa96044a3f:/app/lazy_balancer# python manage.py makemigrations Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 398, in execute self.check() File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 426, in check include_deployment_checks=include_deployment_checks, File "/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py", line 75, in run_checks new_errors = check(app_configs=app_configs) File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 13, in check_url_config return check_resolver(resolver) File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 23, in check_resolver for pattern in resolver.url_patterns: File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 417, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 410, in urlconf_module return import_module(self.urlconf_name) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/app/lazy_balancer/lazy_balancer/urls.py", line 20, in <module> from .views import logout_view,login_view File "/app/lazy_balancer/lazy_balancer/views.py", line 10, in <module> from nginx.ip import * File "/app/lazy_balancer/nginx/ip.py", line 3, in <module> import iptc File "/usr/local/lib/python2.7/dist-packages/iptc/__init__.py", line 10, in <module> from iptc.ip4tc import (is_table_available, Table, Chain, Rule, Match, Target, File "/usr/local/lib/python2.7/dist-packages/iptc/ip4tc.py", line 13, in <module> from .xtables import (XT_INV_PROTO, NFPROTO_IPV4, XTablesError, xtables, File "/usr/local/lib/python2.7/dist-packages/iptc/xtables.py", line 704, in <module> raise XTablesError("can't find directory with extensions; " iptc.xtables.XTablesError: can't find directory with extensions; please set XTABLES_LIBDIR
请问怎么注释掉 iptables 相关代码(想使用,但是不懂)? 或者能否发布一个docker镜像,直接使用就可以了
注释如下: nginx/ip.py line all
lazy_balancer/views.py line 10: from nginx.ip import * line 25: set_firewall()
proxy/views.py line 11: from nginx.ip import * line 227: set_firewall()
settings/views.py line 7: from nginx.ip import set_firewall line 61: set_firewall()
我正在考虑将 iptables 控制取消掉,这样就可以跑在 docker 容器中了;目前临时解决办法是支持 vagrant 方式部署,你可以直接在目录中用 vagrant up 启动项目(请注意修改 box 为你自己的 ubuntu box)
最主要还是django依赖的问题,解决这个问题django有点重。想想办法能不能换个轻量级的。
@wizardbyron 其实 Django 已经很轻量了,主要是很方便的封装了很多实现,比如数据库,缓存,异步任务,配置,路由等。更关键的是有强大的扩展支持,依赖这个东西简单也复杂,各取所需; 后面需要想办法把部分依赖做成可插拔的方式实现就可以支持容器了。 另外这个项目诞生的时候定位的就是虚拟机、轻量级物理机平台(ATOM)等,通过这个项目,可以定制一些简单的物理负载均衡器,解决的是商用负载均衡器性价比和操作复杂的问题。
因为启用了 iptables 控制,所以暂时不支持 docker 方式运行,如果需要使用 Docker,可以注释 iptables 相关代码