From 8ae9c9e87822efa2532b4a90233cb86651aa5b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Tue, 16 Jun 2026 21:09:56 +0200 Subject: [PATCH] fix(update): compare local image store IDs, not running container IDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit docker compose images -q reports the image IDs of currently running containers, which don't change after a pull — so before == after always and containers were never recreated. Fix: resolve each service's image tag to its local SHA256 ID via docker image inspect, which reads the local image store and correctly reflects the newly pulled image. Falls back from 'config --images' (compose v2.19+) to parsing 'config' yaml for older versions. Co-Authored-By: Claude Sonnet 4.6 --- stacks.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/stacks.sh b/stacks.sh index f81140f..21e2ef9 100755 --- a/stacks.sh +++ b/stacks.sh @@ -379,6 +379,24 @@ cmd_compose() { # ─── Update Service ─────────────────────────────────────────────────────────── +# Resolve each service's image tag to its current local SHA256 ID. +# Reads from the local image store (updated by 'docker compose pull'), +# NOT from running containers — so the comparison reflects the pulled image. +_stack_image_ids() { + local stack_dir="$1"; shift + local -a env_flag=("$@") + local images + # 'config --images' (compose v2.19+) outputs one image name per line; + # fall back to parsing the resolved config yaml for older versions. + if images=$(cd "$stack_dir" && docker compose "${env_flag[@]}" config --images 2>/dev/null) \ + && [[ -n "$images" ]]; then + echo "$images" + else + cd "$stack_dir" && docker compose "${env_flag[@]}" config 2>/dev/null \ + | awk '/^\s+image:/{print $2}' | sort -u + fi | xargs -r docker image inspect --format '{{.Id}}' 2>/dev/null | sort +} + _update_run() { load_root_env @@ -398,9 +416,9 @@ _update_run() { ((checked++)) || true local before after - before=$(cd "$stack_dir" && docker compose "${env_flag[@]}" images -q 2>/dev/null | sort || true) + before=$(_stack_image_ids "$stack_dir" "${env_flag[@]+"${env_flag[@]}"}") (cd "$stack_dir" && docker compose "${env_flag[@]}" pull 2>&1) || true - after=$(cd "$stack_dir" && docker compose "${env_flag[@]}" images -q 2>/dev/null | sort || true) + after=$(_stack_image_ids "$stack_dir" "${env_flag[@]+"${env_flag[@]}"}") if [[ "$before" != "$after" ]]; then info " Updates found — recreating $stack"