fix: use rebuild_container instead of docker restart after image pulls

docker restart uses the image ID baked in at container creation — it never
picks up a new digest. rebuild_container reads the stored Unraid XML template,
stops the old container, recreates it with the new image, then handles the
old image cleanup. This is what the Unraid UI 'Apply Update' button does.

docker_update.sh: add rebuild section after pull loop for DAILY containers.
docker_update_remaining.sh: replace retry_docker docker restart with rebuild_container.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gmer4Lfe
2026-05-31 15:09:55 -04:00
co-authored by Claude Sonnet 4.6
parent 55a38b6b74
commit fdba23c32d
2 changed files with 38 additions and 11 deletions
+31 -3
View File
@@ -311,6 +311,32 @@ for container in "${TARGET_CONTAINERS[@]}"; do
done
# ── Recreate containers that received a new image ────────────────────────────
# docker restart uses the image ID baked in at creation time — it never picks
# up the new digest. rebuild_container reads the stored XML template, stops the
# old container, recreates it (new image, same config), then prunes the old image.
REBUILT=()
REBUILD_FAILED=()
if [[ ${#UPDATED[@]} -gt 0 ]]; then
for container in "${UPDATED[@]}"; do
[[ -z "$container" ]] && continue
if [[ "$DRY_RUN" == true ]]; then
warn "DRY RUN — would rebuild $container from template"
REBUILT+=("$container")
continue
fi
log "$ICON_SYNC Rebuilding $container from template on new image..."
if /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/rebuild_container "$container" >/dev/null 2>&1; then
log "$ICON_DONE $container rebuilt ✅"
REBUILT+=("$container")
else
error "Failed to rebuild $container — will be picked up by docker_daily_restart.sh"
notify "$container failed to rebuild after image update on $(hostname)" "Docker Update" "warning"
REBUILD_FAILED+=("$container")
fi
done
fi
# ── Prune dangling images ─────────────────────────────────────────────────────
# Old images become dangling after a pull lands a new digest. Prune here so
# they don't accumulate across daily runs.
@@ -339,9 +365,11 @@ if [[ ${#UPDATED[@]} -gt 0 ]]; then
echo "$ICON_DONE Updated: ${#UPDATED[@]}"
log " ${UPDATED[*]}"
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[*]}"
[[ ${#REBUILT[@]} -gt 0 ]] && echo "$ICON_SYNC Rebuilt: ${#REBUILT[@]}"
[[ ${#REBUILD_FAILED[@]} -gt 0 ]] && echo "$ICON_ERROR Rebuild fail:${REBUILD_FAILED[*]}"
[[ ${#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