diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2016-11-14 05:52:45 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2016-11-14 05:52:45 +0000 |
commit | b32b281201f7408881b52bf8495c42aa5afed0e0 (patch) | |
tree | d79025cca7d78fdedb226caf57a109f55d6b02e1 /tcwg-cleanup-stale-containers.sh | |
parent | db3beb8262f73a0edd2cad6f13cfddda1029f778 (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-x | tcwg-cleanup-stale-containers.sh | 12 |
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 |