Docker Community Forums

Share and learn in the Docker community.

Docker stop gracetime


The application we’re running requires a stop grace time of 30 seconds. (The time between receiving SIGTERM and SIGKILL).

They are simply started using docker run …

It works fine when we shut them down manually using : docker stop master-app -t 30

However, when the host is shutdown by doing systemctl stop docker, the containers are not shut down gracefully.

We’ve tried changing this in the daemon settings but it does not do what we need.

cat /etc/docker/daemon.json <<-‘EOF’
“shutdown-timeout”: 30

Is there something we could do to make systemctl stop docker wait longer before killing containers ?



This might shed some light on the situation: dockerd shutdown-timeout option does not work as expected · Issue #32357 · moby/moby · GitHub

TL;DR: start your container with docker run --stop-timeout 30 ... and it should work as required.

1 Like

Thank you very much! That did the trick!