Stopping And Removing
Part of the Introduction to Docker section of Coddy's Terminal journey — lesson 15 of 40.
To stop a running container, use docker stop with its name or ID:
docker stop webThe container moves from Up to Exited, but it still exists. To delete a stopped container for good, use docker rm:
docker rm webDocker refuses to rm a container that is still running, to protect you from mistakes. If you really mean it, force removal with -f:
docker rm -f webChallenge
EasyStart a detached redis container named db, then stop it, then list all containers so you can see its Exited status.
Cheat sheet
Stop a running container (moves to Exited state but still exists):
docker stop webRemove a stopped container permanently:
docker rm webForce remove a running container:
docker rm -f webTry it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Introduction to Docker
4Managing Containers
Naming ContainersDetached ContainersListing All ContainersStopping And RemovingRecap - Container Lifecycle