Learn Docker:Fundamentals of Docker 19.x
上QQ阅读APP看书,第一时间看更新

Removing containers

When we run the docker container ls -a command, we can see quite a few containers that are in the Exited status. If we don't need these containers anymore, then it is a good thing to remove them from memory; otherwise, they unnecessarily occupy precious resources. The command to remove a container is as follows:

$ docker container rm <container ID>

Another command to remove a container is the following:

$ docker container rm <container name>

Try to remove one of your exited containers using its ID.

Sometimes, removing a container will not work as it is still running. If we want to force a removal, no matter what the condition of the container currently is, we can use the command-line parameter -f or --force.