This uses two containers - one running apt-cacher-ng, and one running rawdns. In fact, this gist is mostly based on the apt-cacher-ng hack documented the rawdns repo.
This includes a few quirks for OS X, which I'll make note of.
- Edit ('create') /etc/rawdns.json to look like the
rawdns.json
in this gist. - Run a rawdns container:
docker run -d --name rawdns -p 53:53/udp -v /var/run/docker.sock:/var/run/docker.sock -v /private/etc/rawdns.json:/etc/rawdns.json:ro tianon/rawdns rawdns /etc/rawdns.json
. Note that this references /private/etc/rawdns.json; this is because on OS X, /etc is symlinked to /private/etc, and you can't mount a symlink. - Update your DNS resolver to use
127.0.0.1
! Assuming OS X, this is in theNetwork
preference pane, behindAdvanced
->DNS
. dig dns.docker
should now includeSERVER: 127.0.0.1#53(127.0.0.1)
.- Ru