summaryrefslogtreecommitdiff
path: root/tcwg-cleanup-stale-containers.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tcwg-cleanup-stale-containers.sh')
-rwxr-xr-xtcwg-cleanup-stale-containers.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/tcwg-cleanup-stale-containers.sh b/tcwg-cleanup-stale-containers.sh
index 84f4a5ea..8cd201e2 100755
--- a/tcwg-cleanup-stale-containers.sh
+++ b/tcwg-cleanup-stale-containers.sh
@@ -186,11 +186,12 @@ if $cleanup_images; then
image_stamp="$stamp_dir/$(echo "$image" | tr "/:" "_")"
remove_if_not_used_since=$(($(date +%s) - 3*24*60*60))
# Use negative comparison to handle non-existent stamp files.
- if ! [ "$(stat -c %Z "$image_stamp.use")" \
+ if ! [ "$(stat -c %Z "$image_stamp.use" 2>/dev/null)" \
-gt $remove_if_not_used_since ] 2>/dev/null; then
# Untag the image. Use $image_id to handle previously-untagged
# images and other cases when we have no repo or tag reference.
- docker rmi -f "$image_id"
+ docker rmi -f "$image_id" 2>/dev/null \
+ || echo "NOTE: Cannot remove $image_tuple"
fi
done
# Prune untagged images.