Skip to content

Instantly share code, notes, and snippets.

@GrahamLea
Created May 20, 2020 13:57
Show Gist options
  • Save GrahamLea/4b9bf8625b5e8088c11e4479a38d6b81 to your computer and use it in GitHub Desktop.
Save GrahamLea/4b9bf8625b5e8088c11e4479a38d6b81 to your computer and use it in GitHub Desktop.
How to cleanup docker containers, images and volumes on your local machine
# 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
@GrahamLea
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment