From c2967301b8b85bce375179118f407b964d09188f Mon Sep 17 00:00:00 2001 From: YashIIT0909 <24je0721@iitism.ac.in> Date: Thu, 9 Apr 2026 02:40:59 +0530 Subject: [PATCH 1/2] feat: add DNS pre-flight check to verify Docker connectivity before startup --- scripts/start | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/start b/scripts/start index 7d1d1925..c0b8a359 100755 --- a/scripts/start +++ b/scripts/start @@ -19,6 +19,32 @@ if [ "$EUID" -eq 0 ] exit 1 fi +# ── DNS Pre-flight Check ───────────────────────────────────────────── +echo "Checking Docker DNS connectivity..." +DNS_OK=false +for i in 1 2 3; do + if docker run --rm alpine wget --spider --timeout=5 https://dl-cdn.alpinelinux.org > /dev/null 2>&1; then + DNS_OK=true + break + fi + [ "$i" -lt 3 ] && sleep 2 +done + +if [ "$DNS_OK" = false ]; then + echo "" + echo -e "\033[1;33m WARNING: Docker DNS resolution failed after 3 attempts.\033[0m" + echo -e "\033[0;33m Containers cannot resolve external domains (e.g. dl-cdn.alpinelinux.org)." + echo " This is commonly caused by a DNS bridge conflict with systemd-resolved." + echo "" + echo " Suggested fixes:" + echo " 1. Add DNS to /etc/docker/daemon.json:" + echo ' { "dns": ["8.8.8.8", "8.8.4.4"] }' + echo " 2. Then run sudo systemctl restart docker" + echo "" + echo -e " The build will continue, but may fail during package installation.\033[0m" + echo "" +fi + if [[ ! -d "${NOSTR_CONFIG_DIR}" ]]; then echo "Creating folder ${NOSTR_CONFIG_DIR}" mkdir -p "${NOSTR_CONFIG_DIR}" From 7dc18307a55d2eabd17c588cfe7ed72f3a34cb3e Mon Sep 17 00:00:00 2001 From: YashIIT0909 <24je0721@iitism.ac.in> Date: Thu, 9 Apr 2026 12:32:18 +0530 Subject: [PATCH 2/2] feat: implement exponential backoff and improved status reporting for Docker DNS pre-flight checks --- scripts/start | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/scripts/start b/scripts/start index c0b8a359..296477e0 100755 --- a/scripts/start +++ b/scripts/start @@ -20,29 +20,42 @@ if [ "$EUID" -eq 0 ] fi # ── DNS Pre-flight Check ───────────────────────────────────────────── -echo "Checking Docker DNS connectivity..." +YELLOW=$'\033[0;33m' +BOLD_YELLOW=$'\033[1;33m' +NC=$'\033[0m' +DNS_TEST_URL="https://dl-cdn.alpinelinux.org" +DNS_MAX_RETRIES=3 DNS_OK=false -for i in 1 2 3; do - if docker run --rm alpine wget --spider --timeout=5 https://dl-cdn.alpinelinux.org > /dev/null 2>&1; then +BACKOFF=2 + +echo "Checking Docker DNS connectivity..." +for i in $(seq 1 $DNS_MAX_RETRIES); do + printf " [Attempt $i/$DNS_MAX_RETRIES] Testing resolution... " + if docker run --rm alpine wget --spider --timeout=5 "$DNS_TEST_URL" > /dev/null 2>&1; then + echo "Success" DNS_OK=true break + else + echo "Failed" fi - [ "$i" -lt 3 ] && sleep 2 + [ "$i" -lt "$DNS_MAX_RETRIES" ] && sleep $BACKOFF && BACKOFF=$((BACKOFF * 2)) done if [ "$DNS_OK" = false ]; then - echo "" - echo -e "\033[1;33m WARNING: Docker DNS resolution failed after 3 attempts.\033[0m" - echo -e "\033[0;33m Containers cannot resolve external domains (e.g. dl-cdn.alpinelinux.org)." - echo " This is commonly caused by a DNS bridge conflict with systemd-resolved." - echo "" - echo " Suggested fixes:" - echo " 1. Add DNS to /etc/docker/daemon.json:" - echo ' { "dns": ["8.8.8.8", "8.8.4.4"] }' - echo " 2. Then run sudo systemctl restart docker" - echo "" - echo -e " The build will continue, but may fail during package installation.\033[0m" - echo "" + cat <&2 + +${BOLD_YELLOW} WARNING: Docker DNS resolution failed after $DNS_MAX_RETRIES attempts.${NC} +${YELLOW} Containers cannot resolve external domains (e.g. dl-cdn.alpinelinux.org). + This is commonly caused by a DNS bridge conflict with systemd-resolved. + + Suggested fixes: + 1. Add DNS to /etc/docker/daemon.json: + { "dns": ["8.8.8.8", "8.8.4.4"] } + 2. Then run sudo systemctl restart docker + + The build will continue, but may fail during package installation.${NC} + +EOF fi if [[ ! -d "${NOSTR_CONFIG_DIR}" ]]; then