0

For example, to run django in production I can use nginx, uwsgi, supervisor

I can have a single docker file which installs all of them and run supervisor

or

I can probably have 3 docker files (nginx, uwsgi, supervisor) and one docker-compose file.

I 've been using the first option and wonder if there's any benefit of using the 2nd form

2 Answers 2

2

I am not sure about the need of supervisor container, but for the uwsgi and Nginx rule of thumb for the contianer

"Single process per container"

dockerfile_best-practices

So better to have 3 container

  • Nginx
  • uwsgi
  • Superviosir

If you want to keep supervisor just for sake managing Nginx process then better to remove this as "update docker image and launch new container is better then restarting process"

Both Nginx and uwsgi will be running as root process of the container and when there is an update, update the image and launch new container is common practice and the health check should be manageable.

Plus you can run one Nginx along with two application container as scaling and flexibility are more when you have one process per container .

Sign up to request clarification or add additional context in comments.

Comments

1

Given that you have nginx and uwsgi serving django, I would recommend to have two services in docker-compose:

  • uwsgi + supervisor
  • Nginx + supervisor

How does this help?

Given uwsgi and nginx are two major processes that describes the availability of your solution, splitting them this way ensures the following:

  1. Separation of concern and flexibility to use nginx for other purposes or solutions
  2. Per service healthchecks (by docker) to up-level precisely where the issue is in case of any failure

6 Comments

Thanks for the answer, suppose I have 2 django apps, right now, I have two sets of uwsgi+supervisor+nginx .. I'm thinking maybe I can run only single nginx at least. does your solution help here?
Yeah, in such a case you can have three services defined in docker-compose.yaml. 1 nginx, 1 uwsgi (serving django app1) + supervisor and 1 uwsgi (serving django app2) + supervisor
great, no way to factor out the supervisor and share it ?
I would recommend keeping it local to managed service so that context of management and monitoring is localized.
Why bring supervisord into this at all? (There's some value in having a light-weight init like tini or letting docker run --init provide it for you, but you shouldn't generally need supervisord, especially splitting things up like this.)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.