Reputation: 21
I am learning to work with Docker containers and I trying what I thought would be a simple exercise, but running into issues. I want to use a container to change the default DNS server that my machine uses.
So when I say
>> host facebook.com
the result should be the same as
>> host facebook.com _myserverIP_
So I looked around and found several images on Docker hub and based on those made this very simple Dockerfile:
FROM alpine:latest
RUN apk --no-cache add dnsmasq
COPY dnsmasq.conf /etc/dsnmasq.conf
EXPOSE 53/tcp 53/udp
VOLUME ["/etc/dnsmasq"]
CMD ["dnsmasq"]
in dnsmasq.conf, I put:
log-queries
no-resolv
server= _myserverIP_
I build and run:
docker build -t dns .
docker run --name dns3 -d -p 53:53/udp --cap-add=NET_ADMIN dns
this gives me 2c3f046593c5d6e664d202e78d92172c75f71b95c45a9ea307af49bd1e2d5125
but when I try to see what containers are running, I see that this container isn't even running, so I can't do the next step of checking if it is working.
I am clearly missing something basic, but can't figure out what.
Upvotes: 1
Views: 2175
Reputation: 373
Your system will look in /etc/resolv.conf
to determine what dns servers to use. Use this guide to determine how dnsmasq uses /etc/resolv.conf
https://wiki.debian.org/HowTo/dnsmasq
I suspect you will need to mount resolv.conf as well.
Upvotes: 1