Created
April 12, 2020 18:21
-
-
Save katoozi/5ede395be16839a685826174d1b5a37e to your computer and use it in GitHub Desktop.
delete docker none images(untagged images)
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
#!/bin/bash | |
RED='\033[0;31m' | |
NC='\033[0m' | |
clean_untagged_docker_images(){ | |
noneImages="$(docker images | grep "^<none>" | awk '{print $3}')" | |
if [ "$noneImages" != "" ]; then | |
docker images | grep "^<none>" | awk '{print $3}' | while read line; do | |
{ | |
docker rmi $line -f | |
} || { | |
echo -e "${RED}Error While Deleteing Images.${NC}" | |
} | |
done | |
fi | |
} | |
clean_untagged_docker_images |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment