Difficulty: Intermediate
What is the difference between 'docker stop' and 'docker kill'?
- **docker stop**: Sends a `SIGTERM` signal to the process, giving it time to shut down gracefully (close DB connections, finish tasks). After a timeout (default 10s), it sends `SIGKILL`. - **docker kill**: Sends `SIGKILL` immediately. The process is terminated abruptly without a chance to clean up.
# Give the app 30 seconds to stop gracefully
docker stop -t 30 my-container
Useful for apps that need more time to finish background jobs during deployment.
Lifecycle, Signals, SIGTERM, SIGKILL