A
A
Andrey2018-09-16 12:42:34
linux
Andrey, 2018-09-16 12:42:34

How to set up a DNS server for a host running in docker?

Good day.
The computer now has dnsmasq installed in DNS server mode. There is only one line in the config so far:

address=/loc/127.0.0.1

Those. all requests to *.loc addresses will be redirected to the local machine.
There was a need to transfer the server to the docker container, configured it in docker-compose.yml in this way:
dns:
    image: andyshinn/dnsmasq:2.78
    volumes:
      - ${PATH_TO_CONFIGS}/dnsmasq/dnsmasq.conf:/etc/dnsmasq.conf
    cap_add:
      - NET_ADMIN
    ports:
      - 53:53/tcp
      - 53:53/udp

And everything would be fine, but on the host (Linux Mint 18) this port is busy by default:
$ sudo netstat -pna | grep :53
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN     2064/dnsmasq
udp        0      0 0.0.0.0:5353            0.0.0.0:*                          1275/avahi-daemon:
udp        0      0 127.0.1.1:53            0.0.0.0:*                          2064/dnsmasq
udp6       0      0 :::5353                 :::*                               1275/avahi-daemon:

And as I found out, 2064/dnsmasq is network-manager.
The question actually is how to make sure that the ports are normally registered. Or, if possible, tell me how you can configure docker so that it takes over the task of the container with dnsmasq.
PS I'm still getting used to docker, so I may not know some subtleties in its operation and configuration, for which I apologize in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-09-16
@sashaaro

You need to run dnsmasq and give it a static ip. do not specify public port, as it is busy.
You can see an example for compose here. linux-notes.org/ispol-zovanie-staticheskogo-ip-adr...
You can create a subnet manually and run it yourself

docker network create some_network
docker run --network some_network --ip 172.19.5.5 --restart=unless-stopped -d dnsmasq

it is necessary to take into account the network mask some_network for the ip parameter.
Checking
. Adding our IP dns server to the system.
echo "nameserver 172.19.5.5" | sudo tee --append /etc/resolvconf/resolv.conf.d/tail
sudo resolvconf -u

Took commands from https://github.com/jderusse/docker-dns-gen#simple-usage
https://askubuntu.com/questions/130452/how-do-i-ad...
Checking
dig postgres.my-project.loc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question