Created
May 20, 2020 13:57
-
-
Save GrahamLea/4b9bf8625b5e8088c11e4479a38d6b81 to your computer and use it in GitHub Desktop.
How to cleanup docker containers, images and volumes on your local machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove containers whose name matches the automatic naming pattern (adjective_name). Won't affect running containers. | |
docker rm $(docker ps -a | awk '{print $NF}' |egrep '^[a-z]+_[a-z]+$') | |
# Delete images that don't have any tags or containers. | |
docker image prune -f | |
# Delete unused volumes | |
docker volume prune -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
c.f. https://docs.docker.com/config/pruning/