Docker for dnsmasq
This is the Dockerfile setup for dnsmasq.
To build the image locally:
git clone https://github.com/blackbarn/docker-dnsmasq.git; cd docker-dnsmasq; docker build -t dnsmasq .
docker run -d -v /your_config_location:/etc/dnsmasq.d -p "53:5353/udp" --name dnsmasq dnsmasq
Or you can replace
blackbarn/dnsmasq in your
run command to use the pre-built image from docker hub.
docker run -d -v /your_config_location:/etc/dnsmasq.d -p "53:5353/udp" --name dnsmasq blackbarn/dnsmasq
Change the port mapping to suit your needs. Say you already have a DNS server listening on another interface and need to lock this one down to another:
docker run -d -v /your_config_location:/etc/dnsmasq.d -p "192.168.1.100:53:5353/udp" --name dnsmasq blackbarn/dnsmasq
See the dnsmasq docs for details, however all you need to do is add
*.conf files to your
/your_config_location/ and dnsmasq will pick them up and try to enforce their rules.
# /your_config_location/config.conf # # send *.docker lookups to another DNS server server=/docker/172.17.42.1 # *.lan hosts/urls get sent to a specific IP address=/.lan/192.168.1.3
An example of a
dns: build: . container_name: dnsmasq volumes: - /data/dnsmasq:/etc/dnsmasq.d ports: - "192.168.1.3:53:5353/udp" restart: always
Obviously your volume mapping will vary.