summaryrefslogtreecommitdiff
path: root/tcwg-cleanup-stale-containers.sh
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2016-11-14 05:52:45 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2016-11-14 05:52:45 +0000
commitb32b281201f7408881b52bf8495c42aa5afed0e0 (patch)
treed79025cca7d78fdedb226caf57a109f55d6b02e1 /tcwg-cleanup-stale-containers.sh
parentdb3beb8262f73a0edd2cad6f13cfddda1029f778 (diff)
tcwg-cleanup-stale-containers: Cleanup untagged images
... which we generate when commiting a container for debugging. If the debug container is still present, then image removal will [expectedly] fail, so only unused images will be removed. Change-Id: If2790d19ff4d944077ebb6f47d36559df20060da
Diffstat (limited to 'tcwg-cleanup-stale-containers.sh')
-rwxr-xr-xtcwg-cleanup-stale-containers.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/tcwg-cleanup-stale-containers.sh b/tcwg-cleanup-stale-containers.sh
index 154b1ce5..9ff23d42 100755
--- a/tcwg-cleanup-stale-containers.sh
+++ b/tcwg-cleanup-stale-containers.sh
@@ -75,4 +75,16 @@ if [ x"$(docker volume ls -q -f dangling=true)" != x"" ]; then
fi
fi
+if [ x"$(docker images | grep "^<none>" | awk "{print $3})" != x"" ]; then
+ echo "Removing untagged images"
+ echo "Increasing exit code by 4 to indicate untagged images"
+ status="$(($status+4))"
+ if ! $dry_run; then
+ docker docker images | grep "^<none>" | awk "{print $3}" | xargs -i@ docker rmi @ | cat
+ echo "xargs docker rmi exit status: ${PIPESTATUS[3]}"
+ else
+ echo "DRY_RUN: NOT REMOVING UNTAGGED IMAGES"
+ fi
+fi
+
exit $status