The Docker engine enables you to start
, stop
, and restart
a container with a set of docker
subcommands. Let's begin with the docker container stop
subcommand, which stops a running container. When a user issues this command, the Docker engine sends SIGTERM (-15)
to the main process, which is running inside the container. The SIGTERM signal requests the process to terminate itself gracefully.
Most of the processes would handle this signal and facilitate a graceful exit. However, if this process fails to do so, then the Docker engine will wait for a grace period. Even after the grace period, if the process has not been terminated, then the Docker engine will forcefully terminate the process. The forceful termination is achieved by sending SIGKILL (-9)
.
The SIGKILL signal cannot be caught or ignored and hence, it will result in an abrupt termination of the process without a proper cleanup.
Now, let's launch our container and experiment with the docker container stop...