docker rm
The docker rm command is used to remove one or more Docker containers. This command deletes the specified containers from the local Docker host.
Basic Syntax
Key Options and Parameters
-f, --force: Force the removal of a running container (uses SIGKILL).
docker rm -f mycontainer-v, --volumes: Remove the volumes associated with the container.
docker rm -v mycontainer-l, --link: Remove the specified link.
docker rm -l mylink--force: Force the removal of a container even if it is running.
docker rm --force mycontainer
Examples
Removing a Single Container
docker rm mycontainerThis command removes the container named
mycontainer.Removing Multiple Containers
docker rm container1 container2 container3This command removes the containers named
container1,container2, andcontainer3.Forcing the Removal of a Running Container
docker rm -f mycontainerThis command forcefully removes the running container named
mycontainer.Removing a Container and Its Volumes
docker rm -v mycontainerThis command removes the container named
mycontainerand its associated volumes.Removing a Link
docker rm -l mylinkThis command removes the link named
mylink.
Conclusion
The docker rm command is essential for removing Docker containers. Understanding its options and parameters allows you to effectively manage and clean up containers on your Docker host.