Skip to content

Instantly share code, notes, and snippets.

@katoozi
Created April 12, 2020 18:21
Show Gist options
  • Save katoozi/5ede395be16839a685826174d1b5a37e to your computer and use it in GitHub Desktop.
Save katoozi/5ede395be16839a685826174d1b5a37e to your computer and use it in GitHub Desktop.
delete docker none images(untagged images)
#!/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