Docker Gunicorn不';不要发出出口信号
我尝试运行Docker容器:nginx、python和psql。我的nginx容器依赖于python容器。但由于gunicorn不发送退出信号,nginx容器无法运行 我试图改变工作者类型:gevent和eventlet,但仍然是一样的Docker Gunicorn不';不要发出出口信号,docker,gunicorn,Docker,Gunicorn,我尝试运行Docker容器:nginx、python和psql。我的nginx容器依赖于python容器。但由于gunicorn不发送退出信号,nginx容器无法运行 我试图改变工作者类型:gevent和eventlet,但仍然是一样的 # docker-compose.yml version: '2' services: nginx: image: nginx:latest container_name: ng02 ports: - "8002:8002
# docker-compose.yml
version: '2'
services:
nginx:
image: nginx:latest
container_name: ng02
ports:
- "8002:8002"
volumes:
- ./src:/src
- ./config/nginx:/etc/nginx/conf.d
- /static:/static
- ./src/media:/media
depends_on:
- web
web:
build: .
container_name: dg02
command: bash -c "python manage.py collectstatic --no-input && python manage.py makemigrations && python manage.py migrate && gunicorn --timeout 300 --workers=3 myapp.wsgi -b 0.0.0.0:8002 -k eventlet"
depends_on:
- db
volumes:
- ./src:/src
- /static:/static
- /media:/media
expose:
- "8002"
db:
image: postgres:latest
container_name: ps02
而docker compose up
的输出如下所示:
dg02 | [2019-09-10 07:29:23 +0000] [1] [INFO] Starting gunicorn 19.9.0
dg02 | [2019-09-10 07:29:23 +0000] [1] [INFO] Listening at: http://0.0.0.0:8002 (1)
dg02 | [2019-09-10 07:29:23 +0000] [1] [INFO] Using worker: eventlet
dg02 | [2019-09-10 07:29:23 +0000] [14] [INFO] Booting worker with pid: 14
dg02 | [2019-09-10 07:29:24 +0000] [15] [INFO] Booting worker with pid: 15
dg02 | [2019-09-10 07:29:24 +0000] [16] [INFO] Booting worker with pid: 16
这就是问题所在<代码>dg02不存在,因此无法启动
ng02
。如何克服此问题?您确定它不起作用吗?Docker Compose取决于:
只是设置了一个要求,即Compose必须在启动nginx
之前启动web
;它无法知道第一个容器是否“就绪”(事实上,常见的故障源是应用程序依赖于:
数据库,并且在数据库就绪之前很久就完成了启动)。当我在没有-d
标志的情况下运行时,我可以观察到ps02(数据库)启动,dg02启动,但没有ng02的迹象,候机楼正在等待我上面贴的线路。
dg02 | [2019-09-10 07:29:23 +0000] [1] [INFO] Starting gunicorn 19.9.0
dg02 | [2019-09-10 07:29:23 +0000] [1] [INFO] Listening at: http://0.0.0.0:8002 (1)
dg02 | [2019-09-10 07:29:23 +0000] [1] [INFO] Using worker: eventlet
dg02 | [2019-09-10 07:29:23 +0000] [14] [INFO] Booting worker with pid: 14
dg02 | [2019-09-10 07:29:24 +0000] [15] [INFO] Booting worker with pid: 15
dg02 | [2019-09-10 07:29:24 +0000] [16] [INFO] Booting worker with pid: 16