docker stop
has a standard timeout of 10s (Reference - Docker Stop). This time window may be to short for the shutdown of mysql or influxdb to reach a consistent state on file system. If I stopped the container by hand, I would shut it down with docker stop -t 60 mysql
. But that is not the default case. The containers are on auto restart and started and stopped with the docker daemon.
If I stop the docker daemon (e.g. on system reboot), the daemon will stop all running container with a timeout of 10 seconds, which can cause inconsistent dbs.
Question: Is there a way to set the global timeout for docker stop
or the daemon stop?
Update 2016-05-03: Added [Feature Request] Add config parameter to change stop timeout for containers or globally #22471 on github.
According to this answer, adding the -t flag will prevent the container from exiting when running in the background. You can then use docker exec -i -t <image> /bin/bash to get into a shell prompt.
Start the daemon manually You may need to use sudo , depending on your operating system configuration. When you start Docker this way, it runs in the foreground and sends its logs directly to your terminal. To stop Docker when you have started it manually, issue a Ctrl+C in your terminal.
Docker has limited patience when it comes to stopping containers. There's a timeout, which is 10 seconds by default for each container. If even one of your containers does not respond to SIGTERM signals, Docker will wait for 10 seconds at least.
To stop one or more running Docker containers, you can use the docker stop command. The syntax is simple: $ docker stop [OPTIONS] CONTAINER [CONTAINER...] You can specify one or more containers to stop.
https://docs.docker.com/engine/reference/commandline/dockerd/
Use the following config
--shutdown-timeout int Set the default shutdown timeout (default 15)
or put it in docker daemon.json like below and restart docker daemon
tee /etc/docker/daemon.json <<-'EOF'
{
"shutdown-timeout": 30,
"live-restore": true
}
EOF
systemctl restart docker
systemctl status docker
I'm pretty sure there isn't a global setting for this. It would be a nice feature, and you should submit an issue to suggest it, and if you have time submit a pull request to implement.
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