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 <justin.cormack@unikernel.com>
This commit is contained in:
Justin Cormack 2016-01-18 14:01:50 +00:00
parent 5e7809d0ad
commit cfafe4f2d3
2 changed files with 20 additions and 0 deletions

View File

@ -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"]

View File

@ -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"
}