Skip to content

Convenience script to remove untagged images #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,14 @@ The script allows me to easily see if there are some data volumes on my disk tha
up a lot of space and are not needed anymore.

You can find more details in my blog post [Listing information for all your named/unnamed data volumes](https://www.guidodiepen.nl/2017/04/listing-information-for-all-your-named-unnamed-data-volumes/)

## docker_remove_untagged_img.sh

The purpose for this script is to remove all untagged images from the docker local registry.
When building the same docker images multiple times, it is easy to leave a lot of them behind
without tags, especially when using `<latest>` tags. These eat up precious space in the
hard drive and have little benefit. The convenience script executes the `docker rmi` command for all
images with no tags assigned.

## License
The contents of this repository are covered under the [MIT License](LICENSE.md)
11 changes: 11 additions & 0 deletions docker_remove_untagged_img.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

if [ ! "$(docker images | grep "^<none>" | awk '{print $3}')" ]; then
echo "No untagged images to remove. Exiting."
exit 0
fi

echo "Removing all untagged images..."
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')

echo "Done."