From c4fcaa280dc4b128853c9f25378cdcde77fa7f6b Mon Sep 17 00:00:00 2001 From: Manuel Castellin Date: Fri, 28 Feb 2020 18:27:11 +0000 Subject: [PATCH 1/3] feat: add script to remove untagged images When using docker all the time to develop new images it is common to leave a lot of untagged images behind. The `docker_remove_untagged_img.sh` removes all docker images from local storage that are not currently assigned to any tag --- docker_remove_untagged_img.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 docker_remove_untagged_img.sh diff --git a/docker_remove_untagged_img.sh b/docker_remove_untagged_img.sh new file mode 100755 index 0000000..d838791 --- /dev/null +++ b/docker_remove_untagged_img.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +if [ ! "$(docker images | grep "^" | awk '{print $3}')" ]; then + echo "No untagged images to remove. Exiting." + exit 0 +fi + +echo "Removing all untagged images..." +docker rmi $(docker images | grep "^" | awk '{print $3}') + +echo "Done." From 890772fde660670ead080c942e5d41565ef6cd85 Mon Sep 17 00:00:00 2001 From: Manuel Castellin Date: Fri, 28 Feb 2020 18:46:00 +0000 Subject: [PATCH 2/3] docs: provide documentation for docker remove untagged utility Documenting what the `docker_remove_untagged_img.sh` script does. --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index ef4c89b..af08f04 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,11 @@ 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 `` tags. These eat up precious space in the +hard drive and have little benefit. The convenience script run the `docker rmi` command for all +images with no tags assigned. From 82f448367b4e87d5e2e42931f952e92c4efd8a17 Mon Sep 17 00:00:00 2001 From: Manuel Castellin Date: Fri, 28 Feb 2020 18:51:16 +0000 Subject: [PATCH 3/3] docs: fix documentation wording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af08f04..ffe0c2f 100644 --- a/README.md +++ b/README.md @@ -27,5 +27,5 @@ You can find more details in my blog post [Listing information for all your name 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 `` tags. These eat up precious space in the -hard drive and have little benefit. The convenience script run the `docker rmi` command for all +hard drive and have little benefit. The convenience script executes the `docker rmi` command for all images with no tags assigned.