From 7c2e9e5fc8abdafe3efbae6a46a431cebf26f54b Mon Sep 17 00:00:00 2001 From: MickLesk <47820557+MickLesk@users.noreply.github.com> Date: Wed, 11 Nov 2026 20:39:03 +0100 Subject: [PATCH] Fall back to public DNS for Alpine containers too The Debian branch checks name resolution before apt-get update and writes public resolvers when it fails. The Alpine branch went straight to apk, and its mirror fallback only tries other host names, so a dead resolver failed every mirror: 73 installs in a week ended in "Failed to install base packages in Alpine container" behind "DNS: transient error". Same check now on Proxmox VE and Incus. --- incus/backend.func | 4 ++++ pve/backend.func | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/incus/backend.func b/incus/backend.func index 70a25c9..e468e36 100644 --- a/incus/backend.func +++ b/incus/backend.func @@ -1037,6 +1037,10 @@ incus_customize_container() { http://dl-cdn.alpinelinux.org/alpine/${alpine_rel}/main http://dl-cdn.alpinelinux.org/alpine/${alpine_rel}/community EOF" + if ! incus_ct_exec /bin/sh -c 'getent hosts dl-cdn.alpinelinux.org >/dev/null 2>&1'; then + msg_warn "Alpine repository DNS resolution failed in container, injecting public DNS servers" + incus_ct_exec /bin/sh -c 'printf "nameserver 8.8.8.8\nnameserver 1.1.1.1\n" >/etc/resolv.conf' + fi incus_ct_exec ash -c "apk add bash newt curl openssh nano mc ncurses jq >/dev/null" || msg_warn "Alpine base package install had issues" elif [[ "${var_os:-debian}" =~ ^(debian|ubuntu|devuan)$ ]]; then sleep 2 diff --git a/pve/backend.func b/pve/backend.func index da4bd73..a958fd0 100644 --- a/pve/backend.func +++ b/pve/backend.func @@ -1192,6 +1192,11 @@ EOF https://dl-cdn.alpinelinux.org/alpine/latest-stable/main https://dl-cdn.alpinelinux.org/alpine/latest-stable/community EOF' + # As for Debian below: with a dead resolver every mirror fails alike. + if ! pct exec "$CTID" -- /bin/sh -c 'getent hosts dl-cdn.alpinelinux.org >/dev/null 2>&1'; then + msg_warn "Alpine repository DNS resolution failed in container, injecting public DNS servers" + pct exec "$CTID" -- /bin/sh -c 'printf "nameserver 8.8.8.8\nnameserver 1.1.1.1\n" >/etc/resolv.conf' + fi _cs_shield_hangup pct exec "$CTID" -- ash -c 'set -a; [ -f /etc/profile.d/90-http-proxy.sh ] && . /etc/profile.d/90-http-proxy.sh; set +a; apk add bash newt curl openssh nano mc ncurses jq' >>"$BUILD_LOG" 2>&1 || { msg_warn "apk install failed (dl-cdn.alpinelinux.org), trying alternate mirrors..." local alpine_exit=0