From 0092fa8b5465f6060c9fd23db51e51c64fdbb489 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Fri, 7 Aug 2026 11:43:32 +0200 Subject: [PATCH] Docker: report container updates instead of prompting, stop auto-updating Portainer Agent, fix addon detection of legacy Portainer (#16298) * Docker: report container updates instead of prompting, stop auto-updating Portainer Agent, fix addon detection of legacy Portainer * Update portainer.sh --- ct/docker.sh | 14 -------------- misc/tools.func | 37 +++++-------------------------------- tools/addon/portainer.sh | 31 ++++++++++++++++++++++--------- 3 files changed, 27 insertions(+), 55 deletions(-) diff --git a/ct/docker.sh b/ct/docker.sh index 1d0a3f447..9f6984027 100644 --- a/ct/docker.sh +++ b/ct/docker.sh @@ -42,20 +42,6 @@ function update_script() { echo -e "${TAB}${TAB}${GN}bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/addon/portainer.sh)\"${CL}" fi - if docker ps -a --format '{{.Names}}' | grep -q '^portainer_agent$'; then - msg_info "Updating Portainer Agent" - $STD docker pull portainer/agent:latest - $STD docker stop portainer_agent - $STD docker rm portainer_agent - $STD docker run -d \ - -p 9001:9001 \ - --name=portainer_agent \ - --restart=always \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v /var/lib/docker/volumes:/var/lib/docker/volumes \ - portainer/agent - msg_ok "Updated Portainer Agent" - fi msg_ok "Updated successfully!" exit } diff --git a/misc/tools.func b/misc/tools.func index d53cc6059..804b76e7c 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -4802,8 +4802,8 @@ EOF # Container Update Check # - Skipped entirely when running unattended / non-interactive - # - Compose-managed containers: offered via Y/N → docker compose pull + up -d - # - Standalone containers: offered via Y/N → image pull only (no stop/rm) + # - Lists containers with a newer image available and the command to update + # them; does not pull/recreate anything itself if [ "$docker_installed" = true ] && ! _docker_is_noninteractive; then msg_info "Checking for container updates" @@ -4841,41 +4841,14 @@ EOF if [[ ${#compose_updates[@]} -eq 0 && ${#standalone_updates[@]} -eq 0 ]]; then msg_ok "All containers are up-to-date" else - local reply + msg_warn "Updates available (not applied automatically):" for entry in "${compose_updates[@]}"; do IFS='|' read -r name image compose_workdir compose_service <<<"$entry" - reply="" - if read -r -t 60 -p "${TAB3}Update ${name} (${image}) via Compose? (auto-no in 60s): " reply (auto-no in 60s): " reply /usr/local/bin/update_portainer +#!/usr/bin/env bash +# Portainer Update Script +type=update bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/addon/portainer.sh)" +UPDATEEOF + chmod +x /usr/local/bin/update_portainer + msg_ok "Created update script (/usr/local/bin/update_portainer)" +} + # ============================================================================== # UPDATE # ============================================================================== @@ -62,6 +78,8 @@ function update() { $STD docker compose up -d --remove-orphans msg_ok "Restarted ${APP}" + ensure_update_script + msg_ok "Updated successfully" exit } @@ -115,15 +133,7 @@ function install() { $STD docker compose up -d msg_ok "Started ${APP}" - # Create update script - msg_info "Creating update script" - cat <<'UPDATEEOF' >/usr/local/bin/update_portainer -#!/usr/bin/env bash -# Portainer Update Script -type=update bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/addon/portainer.sh)" -UPDATEEOF - chmod +x /usr/local/bin/update_portainer - msg_ok "Created update script (/usr/local/bin/update_portainer)" + ensure_update_script echo "" msg_ok "${APP} is reachable at: ${BL}https://${LOCAL_IP}:${DEFAULT_PORT}${CL}" @@ -150,6 +160,9 @@ fi header_info get_lxc_ip +check_docker +check_existing_container + # Check if already installed if [[ -f "$COMPOSE_FILE" ]]; then msg_warn "${APP} is already installed."