From 83ff9fca5e2eeede0a9bcb3a56c20d9b10cf6178 Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Sun, 24 May 2026 23:14:31 -0400 Subject: [PATCH] docker_update: prune dangling images after pull (both normal and remainder modes) Daily restarts create orphaned images that were never cleaned up. Added docker image prune -f section matching docker_update_remaining.sh pattern. Prune runs each cycle so orphans from the previous day's restart are removed daily rather than waiting for the weekly docker_update_remaining.sh sweep. --- Docker_Essentials/docker_update.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Docker_Essentials/docker_update.sh b/Docker_Essentials/docker_update.sh index 8c6834a..05d8f72 100644 --- a/Docker_Essentials/docker_update.sh +++ b/Docker_Essentials/docker_update.sh @@ -30,7 +30,7 @@ # DAILY_RESTART_CONTAINERS — already updated daily # emby + critical-data profiles — updated inline by the weekly sync window # FALLBACK_*_TIER* — owned by the remote server's update cycle -# Pull → compare → restart if updated → prune dangling images. +# Pull → compare → prune dangling images. # # ============================================================================================== # DESIGN PRINCIPLES @@ -313,6 +313,21 @@ done END=$(date +%s) +# ============================================================================================== +# ━━━ Prune Old Images ━━━ +# ============================================================================================== +echo "" +echo "━━━ $ICON_SYNC Pruning Dangling Images — $(date '+%Y-%m-%d %H:%M:%S') ━━━" + +if [[ "$DRY_RUN" == true ]]; then + warn "DRY RUN — would prune dangling images" + PRUNED_SUMMARY="(dry run)" +else + PRUNED_OUTPUT=$(docker image prune -f 2>&1) + [[ "$ENABLE_LOGGING" == "true" ]] && echo "$PRUNED_OUTPUT" | sed 's/^/ /' + PRUNED_SUMMARY=$(echo "$PRUNED_OUTPUT" | grep -E "^Total reclaimed" || echo "nothing reclaimed") +fi + # ============================================================================================== # ━━━ Summary ━━━ # ============================================================================================== @@ -330,6 +345,7 @@ fi [[ ${#UP_TO_DATE[@]} -gt 0 ]] && log "$ICON_RUNNING Up to date: ${#UP_TO_DATE[@]}" [[ ${#SKIPPED[@]} -gt 0 ]] && log "$ICON_WARN Skipped: ${#SKIPPED[@]}" [[ ${#FAILED[@]} -gt 0 ]] && echo "$ICON_ERROR Failed: ${FAILED[*]}" +echo "$ICON_SYNC Pruned: ${PRUNED_SUMMARY:-none}" if [[ "$DRY_RUN" == true ]]; then warn "DRY RUN — no images pulled"