What does Docker STOPSIGNAL do?

When you run docker stop, you are instructing the Docker daemon to send a signal to the process running the container to stop.

By default, it does this by sending a SIGTERM and then wait a short period so the process can exit gracefully. If the process does not terminate within a grace period (10s by default, customisable), it will send a SIGKILL.

However, your application may be configured to listen to a different signal - SIGUSR1 and SIGUSR2, for example.

In these instances, you can use the STOPSIGNAL Dockerfile instruction to override the default.


SIGTERM is the default signal sent to containers to stop them: https://docs.docker.com/engine/reference/commandline/stop/

STOPSIGNAL does allow you to override the default signal sent to the container. Leaving it out of the Dockerfile causes no harm - it will remain the default of SIGTERM.

This being said, it is unclear why the author has explicitly defined the STOPSIGNAL as SIGTERM.

Looking at this commit, we can see that the STOPSIGNAL used to be set to SIGQUIT.

My guess is that they left it in explicitly for documentation's sake after making the change.

Discussion of the change here: https://github.com/nginxinc/docker-nginx/issues/167