What's the Difference Between "docker stop" and "docker kill" Commands?

When managing Docker containers, two commonly used commands are docker stop and docker kill. Although both commands serve the purpose of halting container processes, they exhibit distinct behaviors:

TL;DR Summary

  • docker stop:
    • Initiates a graceful shutdown of containers;
    • Sends a SIGTERM signal to the main process, allowing time for cleanup;
    • Has a configurable grace period (default: 10 seconds) before forced termination.
  • docker kill:
    • Immediately terminates containers by default;
    • Issues a SIGKILL signal forcefully;
    • Allows customization of signals using the --signal flag;
    • Does not have a grace period; termination is immediate.

Comparison: docker stop vs. docker kill

Feature docker stop docker kill
Purpose Initiates graceful shutdown of containers Immediate termination of containers
Signal Issued SIGTERM SIGKILL
Custom Signal No Yes, using --signal flag
Grace Period Configurable (default: 10 seconds) No grace period
Timeout Period Configurable (with --time option) No timeout

docker stop

The docker stop command facilitates a graceful shutdown by sending a SIGTERM signal to the main process inside the container. This signal requests the process to terminate gracefully, allowing time for cleanup tasks before halting.

The grace period is configurable:

docker stop --time=5 <container_name>

It defaults to 10 seconds. After this period, if the container has not gracefully shut down, docker stop will forcefully attempt to terminate it.

docker kill

The docker kill command takes a more abrupt approach by immediately terminating the container. It issues a SIGKILL signal to the main process, forcefully terminating it without giving it an opportunity for a graceful shutdown.

Notably, with docker kill, you have the option to specify a different signal to be sent to the main process inside the container. This can be achieved using the --signal flag, allowing for more flexibility in managing the termination process:

docker kill --signal=SIGINT <container_name>

Unlike docker stop, the docker kill command does not incorporate a timeout period. It forcefully terminates the container without waiting for any compliance or grace period.


This post was published (and was last revised ) by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.