As I create/debug a docker image/container docker seems to be leaving all sorts of artifacts on my system. (at one point there was a 48 image limit) But the last time I looked there were 20-25 images; docker images
.
So the overarching questions are:
and the meta question... what questions have I not asked that need to be?
Here's how I periodically purge my docker host:
Kill running containers:
docker kill $(docker ps -qa)
Delete all containers (and their associated volumes):
docker rm -v $(docker ps -qa)
Remove all images:
docker rmi $(docker images -q)
Delete only the containers that are not running. Parse the "ps" output for the "Exited" string:
docker ps -a | awk '/Exited/ {print $1}' | xargs docker rm -v
Not perfect... Don't give your container the name "Exited" :-)
Docker 1.9 has a new volume command that can be used to purge old volumes
docker volume rm $(docker volume ls -qf dangling=true)
Latest community edition of docker has a new "system prune" command
docker system prune --volumes
This purged unused networks, kill stopped containers, dangling images and any unused volumes.