From c4fcaa280dc4b128853c9f25378cdcde77fa7f6b Mon Sep 17 00:00:00 2001 From: Manuel Castellin Date: Fri, 28 Feb 2020 18:27:11 +0000 Subject: [PATCH] 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."