Is supervisord needed for docker+gunicorn+nginx?

丶灬走出姿态 提交于 2019-12-08 19:16:37

问题


I'm running django with gunicorn inside docker, my entry point for docker is:

CMD ["gunicorn", "myapp.wsgi"]

Assuming there is already a process that run the docker when the system starts and restart the docker container when it stops, do I even need to use supervisord? if gunicorn will crash won't it crash the docker and then restart?


回答1:


The only time you need something like supervisord (or other process supervisor) in a Docker container is if you need to start up multiple independent processes inside the container when the it starts.

For example, if you needed to start both nginx and gunicorn in the same container, you would need to investigate some sort of process supervisor. However, a much more common solution would be to place these two services in two separate containers. A tool like docker-compose helps manage multi-container applications.

If a container exits because the main process exits, Docker will restart that container if you configured a restart policy when you first started it (e.g., via docker run --restart=always ...).




回答2:


The simple answer is no. And yes you can start both nginx and gunicorn in the same container. You can either create a script which executes everything your container needs to run and start it with CMD at the end of your Dockerfile. Or you can combine everything like so:

CMD (cd /usr/src/app && \
     nginx && \
     gunicorn wsgi:application --config ../configs/gunicorn.conf)

Hope that helps!



来源:https://stackoverflow.com/questions/38722154/is-supervisord-needed-for-dockergunicornnginx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!