From cfafe4f2d394770592d41888b18abab67be55043 Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Mon, 18 Jan 2016 14:01:50 +0000 Subject: [PATCH] Add a dnsfix service Test to see if we can reach the DNS server which we get via DHCP. If not fall back to Google public DNS. Some users on OSX seem to get this situation with xhyve, see https://github.com/docker/pinata/issues/551 Signed-off-by: Justin Cormack --- alpine/Dockerfile | 2 ++ alpine/packages/dnsfix/etc/init.d/dnsfix | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100755 alpine/packages/dnsfix/etc/init.d/dnsfix 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" +}