From f66db7142686bcc8069a50da3925c098d595c5a5 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 2 Oct 2026 11:00:42 +0200 Subject: test-build: drop the superseded image after --pull A --pull that moves the tag leaves the previous image untagged, ~23G for current. Remove that specific image right after a successful pull instead of relying on a host-wide prune: other dangling images on the host are left alone, and rmi refuses if a concurrent run still uses it. Co-Authored-By: Claude Opus 5.5 --- test-build | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test-build b/test-build index 56cc291..f719a73 100755 --- a/test-build +++ b/test-build @@ -861,8 +861,20 @@ print_summary() { # so an up-to-date image costs one manifest request. require_image() { if [[ $PULL_IMAGE -eq 1 ]]; then + local old_id new_id + old_id="$(docker image inspect --format '{{.Id}}' "$ACTIVE_IMAGE" 2>/dev/null || true)" echo "Pulling: $ACTIVE_IMAGE" >&2 - docker pull "$ACTIVE_IMAGE" >&2 && return 0 + if docker pull "$ACTIVE_IMAGE" >&2; then + # A pull that moved the tag leaves the old image untagged (~23G for + # current). Drop that one image, not every dangling one on the host; + # rmi refuses if a container (e.g. a concurrent run) still uses it. + new_id="$(docker image inspect --format '{{.Id}}' "$ACTIVE_IMAGE")" + if [[ -n $old_id && $old_id != "$new_id" ]]; then + docker rmi "$old_id" >&2 \ + || echo "WARN: superseded image $old_id still in use; left in place." >&2 + fi + return 0 + fi if docker image inspect "$ACTIVE_IMAGE" >/dev/null 2>&1; then echo "WARN: pull failed; using the local copy, which may be stale." >&2 return 0 -- cgit v1.2.3