docker kill Command
The docker kill command is used to immediately terminate one or more running containers.
Unlike the docker stop command, the docker kill command sends the SIGKILL signal directly to the container's main process, causing the container to stop immediately without gracefully shutting down.
Syntax
docker kill [OPTIONS] CONTAINER [CONTAINER...]
OPTIONS description:
-s, --signal: The signal sent to the container (default is SIGKILL).
Common Signals
- SIGKILL: Forcefully terminate the process (default signal).
- SIGTERM: Request process termination.
- SIGINT: Send an interrupt signal, usually indicating the user requested termination.
- SIGHUP: Hangup signal, usually indicating the terminal is disconnected.
Example
Immediately terminate a container:
docker kill my_container
Immediately terminate the container named my_container.
Send a custom signal:
docker kill -s SIGTERM my_container
Send the SIGTERM signal to the container named my_container instead of the default SIGKILL signal.
Terminate multiple containers at the same time:
docker kill container1 container2 container3
Immediately terminate the containers container1, container2, and container3.
docker killThe command is used to immediately terminate one or more running containers, by sending a signal (default SIGKILL) to the container's main process. Compared todocker stopDifferent,docker killIt does not wait for the container to stop gracefully; instead, it terminates the process directly. This command is useful when you need to quickly stop a container, but should be used with caution to avoid data loss or inconsistency.
other extensions