aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-02 11:00:42 +0200
committerDanilo M. <danix@danix.xyz>2026-10-02 11:00:42 +0200
commitf66db7142686bcc8069a50da3925c098d595c5a5 (patch)
treeb3f5c85de53ed60150f2e5086455112483554b1d
parentded593dc529916f1bf23f2df38f975db1c1e69e8 (diff)
downloadsbo-dockerbuild-f66db7142686bcc8069a50da3925c098d595c5a5.tar.gz
sbo-dockerbuild-f66db7142686bcc8069a50da3925c098d595c5a5.zip
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 <noreply@anthropic.com>
-rwxr-xr-xtest-build14
1 files changed, 13 insertions, 1 deletions
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