I am not asking about the use of supervisor with dockers but just want to have my understanding validated.
I understand that docker runs a single process when it is run. Also, supervisor is used when we need to run multiple process within the container.
I have seen several examples where a container is started from base image and several service are installed and the container is committed to form a new image, all without supervisor.
So, my basic doubt was what is the difference between both approaches.
My understanding is that when docker container is stopped it sends a kill signal to the process with PID 1, PID 1 manages the child process and stops all child which is exactly what is done by supervisor, while we can install multiple process without supervisor only one process can be run when docker run is issued and when container is stopped only the PID 1 will be sent signals and other running process will not be stopped gracefully.
Please confirm how much my understanding about using supervisord is correct.
Thanks
Update Sept 2016 for docker 1.12 (Q4 2016/Q1 2017)
Arnaud Porterie just twitted:
Yes, although it depends on how your main process runs (foreground or background), and how it collects child processes.
That is what is detailed in "Trapping signals in Docker containers"
If the application is in the foreground, meaning the application is the main process in a container (PID1), it could handle signals directly.
But:
The issue is further detailed in "Docker and the PID 1 zombie reaping problem"
Problem with Docker:
Using an image like
phusion/baseimage-docker
help managing one (or several) process(es) while keeping a main process init-compliant.It uses
runit
instead ofsupervisord
, for multi-process management:That image includes a
my_init
script which takes care of the "reaping" issue.