pause vs stop in docker

ibodi picture ibodi · Jul 22, 2018 · Viewed 17.1k times · Source

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.

Answer

Hemant Singh picture Hemant Singh · Jul 22, 2018

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.