【发布时间】:2020-05-29 22:30:33
【问题描述】:
理想的情况是每个容器有一个进程,但是 Flask+uwsgi 和 Nginx 之间有很强的亲和力。
目前我们一起运行它们,但我们应该重构吗?
【问题讨论】:
理想的情况是每个容器有一个进程,但是 Flask+uwsgi 和 Nginx 之间有很强的亲和力。
目前我们一起运行它们,但我们应该重构吗?
【问题讨论】:
是的,重构是个好主意。尝试使服务短暂并仅在其中运行一个主进程。所以,最后,你需要有这样的东西:
version: '3.4'
services:
web:
build:
dockerfile: Dockerfile
context: .
ports:
- 8000:8000
volumes:
- .:/app/
env_file:
- common.env
nginx:
restart: always
image: nginx:1.18-alpine
ports:
- 80:80
- 443:443
volumes:
- ./deployment/nginx.conf:/etc/nginx/conf.d/default.conf
- ./deployment/config.conf:/etc/nginx/nginx.conf
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\";'"
depends_on:
- web
它被设计为在一个容器中只有一个主进程,在这种情况下,如果您的应用程序失败,该容器将关闭。
【讨论】: