Skip to content

Commit d4b2ea9

Browse files
committed
Clean up old engine images on every update, not just engine upgrades (#45)
Image cleanup previously only ran when the engine version changed. Users who already had v3.3.32 but accumulated old images from prior upgrades wouldn't see cleanup until the next engine bump. Now runs after every update check regardless of whether the engine changed.
1 parent 5d2274e commit d4b2ea9

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

mtproxymax.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3318,22 +3318,22 @@ self_update() {
33183318
load_secrets
33193319
restart_proxy_container
33203320
fi
3321-
# Clean up old engine images (keep only the current version + latest)
3322-
local _old_img
3323-
while IFS= read -r _old_img; do
3324-
[ -z "$_old_img" ] && continue
3325-
[[ "$_old_img" == *":${_expected_ver}" ]] && continue
3326-
[[ "$_old_img" == *":latest" ]] && continue
3327-
docker rmi "$_old_img" 2>/dev/null && log_info "Removed old image: ${_old_img}"
3328-
done <<< "$(docker images --format '{{.Repository}}:{{.Tag}}' 2>/dev/null | grep "^${DOCKER_IMAGE_BASE}:")"
3329-
# Also clean registry-prefixed copies
3330-
while IFS= read -r _old_img; do
3331-
[ -z "$_old_img" ] && continue
3332-
[[ "$_old_img" == *":${_expected_ver}" ]] && continue
3333-
[[ "$_old_img" == *":latest" ]] && continue
3334-
docker rmi "$_old_img" 2>/dev/null || true
3335-
done <<< "$(docker images --format '{{.Repository}}:{{.Tag}}' 2>/dev/null | grep "^${REGISTRY_IMAGE}:")"
33363321
fi
3322+
3323+
# Clean up old engine images (keep only the current version + latest)
3324+
local _old_img
3325+
while IFS= read -r _old_img; do
3326+
[ -z "$_old_img" ] && continue
3327+
[[ "$_old_img" == *":${_expected_ver}" ]] && continue
3328+
[[ "$_old_img" == *":latest" ]] && continue
3329+
docker rmi "$_old_img" 2>/dev/null && log_info "Removed old image: ${_old_img}"
3330+
done <<< "$(docker images --format '{{.Repository}}:{{.Tag}}' 2>/dev/null | grep "^${DOCKER_IMAGE_BASE}:")"
3331+
while IFS= read -r _old_img; do
3332+
[ -z "$_old_img" ] && continue
3333+
[[ "$_old_img" == *":${_expected_ver}" ]] && continue
3334+
[[ "$_old_img" == *":latest" ]] && continue
3335+
docker rmi "$_old_img" 2>/dev/null || true
3336+
done <<< "$(docker images --format '{{.Repository}}:{{.Tag}}' 2>/dev/null | grep "^${REGISTRY_IMAGE}:")"
33373337
}
33383338

33393339
# ── Section 14: Telegram Integration ────────────────────────

0 commit comments

Comments
 (0)