Skip to content

Instantly share code, notes, and snippets.

@mko-x
Created February 22, 2015 18:49
Show Gist options
  • Save mko-x/ed488944bcd2f488cd34 to your computer and use it in GitHub Desktop.
Save mko-x/ed488944bcd2f488cd34 to your computer and use it in GitHub Desktop.
docker.rmi.none - removes all untagged images ( REPOSITORY = <none> )
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