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 directly sends a SIGKILL signal to the container's main process, causing the container to stop immediately without a graceful shutdown.
Syntax
docker kill [OPTIONS] CONTAINER [CONTAINER...]
OPTIONS description:
-s, --signal: The signal sent to the container (SIGKILL by default).
Common signals
- SIGKILL: Forcefully terminate a process (the default signal).
- SIGTERM: Request a process to terminate.
- SIGINT: Send an interrupt signal, usually indicating a user request to terminate.
- SIGHUP: Hangup signal, usually indicating a terminal disconnect.
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 a SIGTERM signal to the container named my_container instead of the default SIGKILL signal.
Terminate multiple containers at once:
docker kill container1 container2 container3
Immediately terminate the container1, container2, and container3 containers.
docker kill The command is used to immediately terminate one or more running containers by sending a signal (SIGKILL by default) to the container's main process. Compared with docker stop in Vue 2,docker kill the docker stop command, it does not wait for the container to stop gracefully but terminates the process directly. This command is very useful when you need to stop containers quickly, but it should be used with caution to avoid data loss or inconsistency.
Docker Command Reference