Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Docker Clean Up!
# Author: Jarek Przygódzki <>
# Docker 1.9+
# In Docker 1.9, there is the ability to manage volumes better
# with docker volume (see
# Delete all stopped containers
echo "Delete all stopped containers"
docker ps -q -f status=exited | xargs --no-run-if-empty docker rm
# Delete all dead containers
echo "Delete all dead containers"
docker ps -q -f status=dead | xargs --no-run-if-empty docker rm
# Delete all dangling (unused) images
echo "Delete all dangling (unused) images"
docker images -q -f dangling=true | xargs --no-run-if-empty docker rmi
# Delete all dangling (orphaned) volumes
echo "Delete all dangling (orphaned) volumes"
docker volume ls -qf dangling=true | xargs --no-run-if-empty docker volume rm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment