How to gracefully shut down monogodb 0.8 running in docker

I am not sure to understand. docker stop <id> will indeed send a SIGTERM. This is by design. If the process didn't shutdown properly within the timeout (default is 10 sec), then a SIGKILL is emitted.

At the moment, we do have some issue with the signal propagation though. It is due to the pid namespace and the fact that the process has a pid 1. This should get fixed soon with the new execution plugins.


Using Docker 0.9 or later, it will send SigTerm to the 1st process (which is running inside container) by default.

But notice the environment variable file (/etc/default/docker in Ubuntu and /etc/sysconfig/docker in CentOS) should include DOCKER_OPTS=" -r=false " (or other_args=" -r=false" in CentOS) for stopping docker from autorestart container.

For example, I'm using this configuration: DOCKER_OPTS=" -g /mydir/docker -r=false --dns 8.8.4.4 "

If you want to run multi-process inside one container, you should using supervisord as the 1st process, supervisord will manage other processes and transfer signals to them.


I'm using docker 0.9. SIGTERM will be sent to process with PID=1 inside a container when call docker stop . So we can manage sub-processes with supervisord, runit.

The problem is when we call $ service docker stop|restart, or the host machine reset. Docker will not send SIGTERM to all running containers. I'm trying to solve this case.