feat: add DNS pre-flight check to verify Docker connectivity before s…#398
Conversation
scripts/start
Outdated
| 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 |
There was a problem hiding this comment.
could you please add some logging here to indicate what is happening to the user?
And can we also set an exponential backoff on the sleep command so it waits 2s the first time, 4s, the second time, and then 8s? Any thoughts?
There was a problem hiding this comment.
I agree that exponential backoff is a more robust way to handle the bridge stabilization period-I’ll implement the 2s/4s/8s sequence.
Regarding the logs, I’ll add the required logging to indicate the status of each attempt.
I'll push the updated code shortly.
| 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 |
There was a problem hiding this comment.
should this message go to stderr?
should we use HEREDOC for the multiline message?
There was a problem hiding this comment.
Great points. Sending the warning to stderr is definitely better practice for diagnostic messages, and using a HEREDOC would be a cleaner approach . I'll refactor the block using cat <&2 to address both. Pushing the update shortly !
Add DNS connectivity pre-flight check to relay startup
Description
This PR adds a defensive pre-flight check to
./scripts/startthat verifies if Docker containers can correctly resolve external domains before starting the build process.The implementation:
dl-cdn.alpinelinux.orgfrom a lightweight temporary Alpine container.Related Issue
#395
Motivation and Context
Linux users (especially on Arch and Ubuntu) frequently encounter DNS bridge conflicts between Docker and
systemd-resolved. This usually results in a crypticEAI_AGAINerror deep in thedocker buildlogs (duringapk addornpm install).By moving this check to the very beginning of the startup script, we provide users with immediate, actionable feedback, saving them time spent debugging low-level Docker networking issues.
How Has This Been Tested?
nslookuptowget --spiderto avoid known BusyBox parsing bugs in Alpine that cause false negatives.--rmflag prevents any orphaned containers from being left behind.Screenshots (if appropriate):
N/A
Types of changes
Checklist: