Created
February 22, 2015 18:49
-
-
Save mko-x/ed488944bcd2f488cd34 to your computer and use it in GitHub Desktop.
docker.rmi.none - removes all untagged images ( REPOSITORY = <none> )
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
do_remove_none_images() { | |
# find untagged images | |
IMAGE_IDS=$(docker images | grep "^<none>" | awk '{print $"3"}') | |
# in case of no untagged images found do nothing | |
if [ -n "$IMAGE_IDS" ]; then | |
docker rmi $IMAGE_IDS > /dev/null 2>&1 | |
fi | |
} | |
alias d.rmi.none=do_remove_none_images | |
# you may use a cron job to execute the cleaning repeatingly | |
# best solution is to run an interval image cleaning container | |
# have a look at https://github.com/mko-x/docker-image-take-down |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment