Last active
September 24, 2024 14:37
-
-
Save etiennemarais/fcda8a3c02c4ae64c511ab805608ad80 to your computer and use it in GitHub Desktop.
Quick alias to remove and clean untagged docker images and stopped containers.
This file contains 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
# | |
# Credit to http://jimhoskins.com/2013/07/27/remove-untagged-docker-images.html | |
# | |
# Add this to your bash profile. | |
# | |
clean_docker () { | |
# Remove stopped containers | |
docker rm $(docker ps -a -q); | |
# Remove untagged images | |
docker rmi $(docker images | grep "^<none>" | awk "{print $3}"); | |
# Remove dangling volumes | |
docker volume rm $(docker volume ls -qf dangling=true) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment