Docker Documentation References:
Other documentation:
Melissa Anderson - How To Remove Docker Images, Containers, and Volumes
The purpose of this kata is to familiarize yourself with the process of removing all exited containers from your docker configuration.
WARNING: This will delete those containers and you will need to recreate them. Do NOT execute this Kata against your local configuration unless you are willing to recreate all of your containers.
In this exercise, we will list all of the exited containers on our system, then we will delete them, and relist the exited containers. Note that this action is not recoverable, don't execute this kata unless your ok with loosing your containers.
Command
docker ps -a -f status=exited
Output
thought:DockerKata rich$ docker ps -a -f status=exited
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4b8cadc3e0a8 e75fa49659ec "sh" 18 minutes ago Exited (0) 16 minutes ago lucid_stonebraker
5a8565827a32 e75fa49659ec "/bin/sh -c ls" 20 minutes ago Exited (0) 20 minutes ago affectionate_joliot
thought:DockerKata rich$
WARNING: This will delete those containers and you will need to recreate them. Do NOT execute this Kata against your local configuration unless you are willing to recreate all of your containers.
Command
docker rm $(docker ps -a -f status=exited -q)
Output
thought:DockerKata rich$ docker rm $(docker ps -a -f status=exited -q)
4b8cadc3e0a8
5a8565827a32
WARNING: This will delete those containers and you will need to recreate them. Do NOT execute this Kata against your local configuration unless you are willing to recreate all of your containers.
Command
docker ps -a -f status=exited
Output
thought:DockerKata rich$ docker ps -a -f status=exited
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES