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 ?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With