Created
November 6, 2019 11:40
-
-
Save jgwerner/d2436c3006d11c1953a0ab894691d041 to your computer and use it in GitHub Desktop.
Alternative to docker images purge to remove dangling 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
# remove docker images by line in text file | |
# alternative to `docker images purge` | |
!/bin/bash | |
images_file=dangling_images.txt | |
list_dangling_images () { | |
docker images --filter dangling=true | while read IMAGE_ID; do | |
>> $images_file | |
done | |
} | |
remove_dangling_images () { | |
while IFS= read -r line | |
do | |
# display $line or do somthing with $line | |
docker rmi -f "$line" | |
done < $images_file | |
} | |
main () { | |
list_dangling_images | |
remove_dangling_images | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment