What is the difference between docker stop and docker kill?
Answer
Both stop a running container but they do it differently: docker stop: sends a SIGTERM signal to the main process inside the container, giving it a chance to shut down gracefully — flush pending writes, close database connections, finish in-flight requests. After a timeout period (default 10 seconds, configurable with -t), if the process hasn't stopped, Docker sends SIGKILL to force-stop it. This is the recommended way to stop containers. Custom timeout: docker stop -t 30 mycontainer. docker kill: sends SIGKILL immediately (or any specified signal) — terminates the process instantly without waiting for graceful shutdown. Use with a custom signal: docker kill --signal SIGHUP mycontainer — useful for sending reload signals to nginx, etc. When to use each: use docker stop (default) for normal operations — allows the application to handle the signal for graceful shutdown; use docker kill only when a container is frozen or unresponsive to SIGTERM. For proper graceful shutdown, your application must handle SIGTERM — use exec form in CMD/ENTRYPOINT so signals are sent directly to your app process, not to a shell wrapper.