Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pause vs stop in docker

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.

like image 665
ibodi Avatar asked Jul 22 '18 14:07

ibodi


People also ask

What is the difference between stop and pause in docker?

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.

What does docker pause do?

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.

Can we pause docker container?

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.

Does docker stop kill all processes?

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.


1 Answers

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.

like image 108
Hemant Singh Avatar answered Sep 24 '22 14:09

Hemant Singh