pause vs stop in docker
And addition to the answers added earlier
running docker events
after docker stop
shows events
- kill (signal 15): where signal 15 = SIGTERM
- die
- stop
running docker events
after docker pause
shows only one event
- pause
Also docker pause
would still keep memory portion while the container is paused. This memory is used when the container is resumed. docker stop
releases the memory used after the container is stopped.
This table has even more details.
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.