I am trying to understand what is the difference between the commands docker stop ContainerID
and docker pause ContainerID
. According to this page both of them are used to pause an existing Docker container.
The Docker pause command is used to pause an existing Docker container. The Docker stop command is used to pause an existing Docker container. The Docker run command is used to put a container back from a stopped state to a running state.
The docker pause command suspends all processes in the specified containers. On Linux, this uses the freezer cgroup. Traditionally, when suspending a process the SIGSTOP signal is used, which is observable by the process being suspended.
Pause ContainerIf we want to pause the processes running inside the container, we can use the “docker pause” command. To unpause the container, use “docker unpause” command.
But, Docker will force shut down (kill the processes) by the time it takes 10 seconds to stop them gracefully. Show activity on this post. docker stop will send SIGTERM (terminate signal) to the process and docker will have 10 seconds to clean up like saving files or emitting some messages.
The docker pause
command suspends all processes in the specified containers. On Linux, this uses the cgroups freezer. Traditionally, when suspending a process the SIGSTOP signal is used, which is observable by the process being suspended
https://docs.docker.com/engine/reference/commandline/pause/
The docker stop
command. The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL.
https://docs.docker.com/engine/reference/commandline/stop/#options
SIGTERM
is the termination signal. The default behavior is to terminate the process, but it also can be caught or ignored. The intention is to kill the process, gracefully or not, but to first allow it a chance to cleanup.
SIGKILL
is the kill signal. The only behavior is to kill the process, immediately. As the process cannot catch the signal, it cannot cleanup, and thus this is a signal of last resort.
SIGSTOP
is the pause signal. The only behavior is to pause the process; the signal cannot be caught or ignored. The shell uses pausing (and its counterpart, resuming via SIGCONT) to implement job control.
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