How to gracefully shut down monogodb 0.8 running in docker

canadadry picture canadadry · Feb 18, 2014 · Viewed 13.6k times · Source

I am starting mongodb via the ENTRYPOINT config in a docker file. It works fine. However, when I execute:

docker stop <containerid>

it seems to be sending a SIGTERM to the process. Which means the mongod.lock file is not cleared. How can I gracefully shutdown a running docker container so that the right signals are sent to the process running inside docker ?

Answer

creack picture creack · Feb 18, 2014

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.