- version: "2"
- services:
- docker-dns:
- container_name: docker-dns
- image: andyshinn/dnsmasq
- hostname: docker-dns
- volumes:
- - /dockerdata/docker-dns/resolv.dnsmasq:/etc/resolv.dnsmasq
- - /dockerdata/docker-dns/dnsmasqhosts/:/etc/dnsmasqhosts
- - /dockerdata/docker-dns/dnsmasq.conf/:/etc/dnsmasq.conf
- - /etc/localtime:/etc/localtime:ro
- ports:
- - 53:53/tcp
- - 53:53/udp
- cap-add: NET_ADMIN
- restart: on-failure:1
dnsmasq requires NET_ADMIN
capabilities to run correctly. Start it with something like docker run -p 53:53/tcp -p 53:53/udp --cap-add=NET_ADMIN andyshinn/dnsmasq:2.75
.
The configuration is all handled on the command line (no wrapper scripts here). The ENTRYPOINT
is dnsmasq -k
to keep it running in the foreground. If you wanted to send requests for an internal domain (such as Consul) you can forward the requests upstream using something like docker run -p 53:53/tcp -p 53:53/udp --cap-add=NET_ADMIN andyshinn/dnsmasq:2.75 -S /consul/10.17.0.2
. This will send a request for redis.service.consul
to 10.17.0.2