Docker Config Reference (docker kill)
We go over several examples of using the docker kill command
Example 1
docker kill mycontainer
This command sends the default SIGKILL signal to the container named "mycontainer", forcibly terminating its main process, which is suitable for immediate shutdown in unresponsive scenarios where graceful termination is not required.
Example 2
docker kill --signal=SIGTERM gracefulcont
This command transmits a SIGTERM signal to "gracefulcont", allowing the container to perform cleanup operations before stopping, ideal for applications that support orderly shutdowns to preserve data integrity.
Example 3
docker kill a1b2c3d4e5f6
This command kills a container identified by its partial ID "a1b2c3d4e5f6", providing flexibility when container names are unknown or for scripted operations referencing IDs from listings.
Example 4
docker kill cont1 cont2
This command simultaneously kills multiple containers "cont1" and "cont2", enabling batch termination in multi-container environments to streamline resource management.
Example 5
docker kill --signal=SIGINT interactivecont
This command sends a SIGINT signal to "interactivecont", simulating a keyboard interrupt for processes that handle such signals, useful in testing interruptible applications.
Example 6
docker kill --signal=9 longrunningcont
This command uses the numeric signal 9 (SIGKILL) to terminate "longrunningcont", ensuring immediate cessation for hung or resource-intensive processes.
Example 7
docker kill f6e5d4c3b2a1
This command kills a container by its full ID "f6e5d4c3b2a1", ensuring precision in environments with similarly named containers.
Example 8
docker kill --signal=SIGHUP configreloadcont
This command sends a SIGHUP signal to "configreloadcont", prompting configuration reloads in applications that interpret this signal, without full termination.
Example 9
docker kill dbcont webcont appcont
This command kills a group of containers "dbcont", "webcont", and "appcont", facilitating coordinated shutdowns in multi-tier applications.
Example 10
docker kill --signal=SIGUSR1 customsigcont
This command transmits a user-defined SIGUSR1 signal to "customsigcont", allowing custom handling in applications designed to respond to such signals for specific behaviors.
Example 11
docker kill 1234567890ab
This command terminates a container by its shortened ID "1234567890ab", convenient for quick actions from docker ps outputs.
Example 12
docker kill --signal=15 termcont
This command uses the numeric equivalent 15 for SIGTERM on "termcont", promoting portability in scripts across different signal naming conventions.
Example 13
docker kill batchjobcont
This command kills the batch job container "batchjobcont", interrupting long-running tasks when immediate cessation is necessary due to errors or timeouts.
Example 14
docker kill --signal=SIGQUIT quitcont
This command sends a SIGQUIT signal to "quitcont", potentially generating a core dump for debugging in applications that support it.
Example 15
docker kill testcont1 testcont2
This command kills test containers "testcont1" and "testcont2", streamlining cleanup after integration testing phases.
Example 16
docker kill --signal=SIGUSR2 usr2cont
This command delivers a SIGUSR2 signal to "usr2cont", enabling application-specific actions like toggling debug modes.
Example 17
docker kill abcdef123456
This command terminates a container by ID "abcdef123456", applicable in automated monitoring systems detecting anomalies.
Example 18
docker kill --signal=TERM gracefulmulti contA contB
This command sends SIGTERM to multiple containers "contA" and "contB", coordinating graceful shutdowns in distributed systems.
Example 19
docker kill stuckcont
This command forcibly kills the stuck container "stuckcont", resolving unresponsiveness in resource-bound scenarios.
Example 20
docker kill --signal=INT keyboardcont
This command simulates a CTRL-C interrupt with SIGINT to "keyboardcont", testing application handling of user interruptions.
Example 21
docker kill 7890abcdef12
This command kills a container by ID "7890abcdef12", for precise targeting in large-scale container orchestrations.
Example 22
docker kill --signal=HUP reloadcont
This command sends SIGHUP to "reloadcont", triggering reloads in services like proxies without downtime.
Example 23
docker kill prodcont stagingcont
This command kills production and staging containers "prodcont" and "stagingcont", for environment-specific resets.
Example 24
docker kill --signal=USR1 signal1cont
This command uses SIGUSR1 on "signal1cont", for custom signaling in event-driven applications.
Example 25
docker kill loopcont
This command kills the infinite loop container "loopcont", breaking resource-consuming cycles.
Example 26
docker kill --signal=QUIT dumpcont
This command sends SIGQUIT to "dumpcont", requesting a core dump for crash analysis.
Example 27
docker kill fedcba987654
This command terminates a container by reversed ID example "fedcba987654", illustrating ID-based flexibility.
Example 28
docker kill --signal=TERM allconts contX contY contZ
This command gracefully kills multiple containers "contX", "contY", and "contZ" with SIGTERM.
Example 29
docker kill unresponsivecont
This command forcibly terminates the unresponsive container "unresponsivecont", restoring system resources.
Example 30
docker kill --signal=USR2 signal2cont
This command delivers SIGUSR2 to "signal2cont", activating secondary custom functions in the application.