Public Repository

Last pushed: 2 years ago
Short Description
Prepends docker host resolv.conf with container resolv.conf file
Full Description

===== Usage =====
docker run -d -v /etc/resolv.conf:/tmp/resolv.conf kgray/dns

To specify which nameservers to add to the resolv.conf file, use the --dns --dns-search and --dns-opt options with docker run.

===== Dockerfile =====
FROM busybox
COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]

===== docker-entrypoint.sh =====

#!/bin/sh
backupDns() {
cp -p /tmp/resolv.conf /tmp/resolv.conf.backup
}

prependDns() {
printf "%b" "$(cat /etc/resolv.conf)\n$(cat /tmp/resolv.conf)\n" > /tmp/resolv.conf
}

restoreDns() {
printf "%b" "$(cat /tmp/resolv.conf.backup)\n" > /tmp/resolv.conf
rm /tmp/resolv.conf.backup
exit
}

trap restoreDns INT TERM

backupDns
prependDns

while true; do
sleep 5 # Do nothing
done

Docker Pull Command
Owner
kgray