diff --git a/alpine/Dockerfile b/alpine/Dockerfile index a643a7eb0..ea89b807a 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -36,6 +36,7 @@ COPY packages/automount/etc /etc/ COPY packages/9pinit/etc /etc/ COPY packages/ntp15m/etc /etc/ COPY packages/binfmt_misc/etc /etc/ +COPY packages/dnsfix/etc /etc/ RUN \ rc-update add swap boot && \ @@ -68,6 +69,7 @@ RUN \ rc-update add automount boot && \ rc-update add diagnostics default && \ rc-update add binfmt_misc sysinit && \ + rc-update add dnsfix boot && \ ln -s /bin/busybox /init CMD ["/bin/sh"] diff --git a/alpine/packages/dnsfix/etc/init.d/dnsfix b/alpine/packages/dnsfix/etc/init.d/dnsfix new file mode 100755 index 000000000..4db7db0bb --- /dev/null +++ b/alpine/packages/dnsfix/etc/init.d/dnsfix @@ -0,0 +1,18 @@ +#!/sbin/openrc-run + +# A few users have reported not being able to access the nameserver on OSX +# If a lookup fails, fall back to Google public nameserver + +depend() +{ + after networking +} + +start() +{ + ebegin "Testing DNS resolution" + + dig www.docker.com 2>&1 > /dev/null || printf "nameserver 8.8.8.8\nnameserver 8.8.4.4\n" > /etc/resolv.conf + + eend $? "DNS fix failed" +}