docker stop
The docker stop command is used to stop one or more running containers. This command sends a SIGTERM signal to the main process inside the container, giving it a chance to gracefully shut down.
Basic Syntax
Key Options and Parameters
-t, --time: Seconds to wait for the container to stop before killing it (default is 10 seconds).
docker stop -t 5 mycontainer
Examples
Stopping a Single Container
docker stop mycontainerThis command stops the container named
mycontainer.Stopping Multiple Containers
docker stop container1 container2 container3This command stops the containers named
container1,container2, andcontainer3.Stopping a Container with a Custom Timeout
docker stop -t 20 mycontainerThis command stops the container named
mycontainerand waits 20 seconds for it to gracefully shut down before forcefully killing it.
Conclusion
The docker stop command is essential for stopping running containers. Understanding its options and parameters allows you to effectively manage the shutdown process of your Docker containers.