Removing containers

When we run the docker container ls -a command, we can see quite a few containers that are in status Exited. 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:

$ docker container rm <container ID> 

Another command to remove a container is:

$ 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.