From d956c8f267b68d44f20909dbe8ee044ab7dde100 Mon Sep 17 00:00:00 2001 From: Benjamin DERVILLE Date: Fri, 2 Jan 2026 12:05:46 +0100 Subject: [PATCH] fix(scripts): add containerd.io fallback for Docker install When apt resolves a newer containerd.io version from Docker's repository metadata but the .deb file is not yet available (or temporarily missing) on the Docker CDN, the install fails with 404 errors. This adds a fallback strategy that: 1. Attempts the normal Docker install (unchanged behavior) 2. If it fails, refreshes apt metadata and enumerates available versions 3. Retries installation by pinning each available version (newest to oldest) This handles transient Docker repo/CDN sync issues gracefully without hard-coding a specific containerd version. --- scripts/install.sh | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index e37b824..7987abc 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -183,6 +183,43 @@ apt_install() { return 1 } +# --- FIX: Docker install with containerd.io fallback (handles repo/CDN 404) --- +install_docker_packages() { + # First try the normal install + if apt_install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin; then + return 0 + fi + + echo "Docker install failed; trying containerd.io version fallback..." >&2 + + # Force refresh lists (helps if repo was mid-sync) + rm -rf /var/lib/apt/lists/* + apt-get update -yq || true + + # Get all available containerd.io versions, newest first (madison output is usually already newest-first, + # but we don't assume; we just iterate in listed order). + mapfile -t versions < <(apt-cache madison containerd.io | awk '{print $3}' | sed '/^$/d') + + if [[ "${#versions[@]}" -eq 0 ]]; then + echo "No containerd.io versions found via apt-cache madison." >&2 + return 1 + fi + + for v in "${versions[@]}"; do + echo "Trying containerd.io=$v ..." >&2 + if apt-get install -yq \ + -o Dpkg::Options::=--force-confdef \ + -o Dpkg::Options::=--force-confold \ + "containerd.io=$v" docker-ce docker-ce-cli docker-buildx-plugin docker-compose-plugin; then + return 0 + fi + done + + echo "All containerd.io fallback versions failed." >&2 + return 1 +} +# --- END FIX --- + # Adds the Docker repository to the system add_docker_repo() { install -m 0755 -d /etc/apt/keyrings @@ -247,7 +284,7 @@ run_cmd "Installing base packages" apt_install ca-certificates git jq curl gnupg printf '\n' printf "Installing Docker\n" run_cmd "${CHILD_MARK} Adding Docker repository" add_docker_repo -run_cmd "${CHILD_MARK} Installing Docker packages" apt_install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin +run_cmd "${CHILD_MARK} Installing Docker packages" install_docker_packages # Ensure Docker service is running run_cmd "${CHILD_MARK} Enabling Docker service" systemctl enable --now docker