Setting up a DNS server as a container - CCI-MOC/rubicon-issues GitHub Wiki

About

We thought about using a VMs to easily work through different scenarios without destroying the server over and over again. So I thought what could be a more proper solution for us then using containers instead. In this doc I will be showing how to set up a simple docker container to enable a DNS service.

some reference links:

assumptions

  1. you are working on rhel or centos using root
  2. you have podman installed - you can still use docker but that's just an alias to podman in RHEL see this link for explanation

Installation

For the BIND to preserve its state across container shutdown and startup you should mount a volume at /data. SELinux users should update the security context of the host mountpoint so that it plays nicely with Podman:

mkdir -p /srv/docker/bind
chcon -Rt svirt_sandbox_file_t /srv/docker/bind

Now just use this command with the modifications you need for your system:

podman run -d --name=bind --dns=127.0.0.1 \
  --publish=10.30.4.1:53:53/udp --publish=129.10.5.144:10000:10000 \
  --volume=/srv/docker/bind:/data \
  --env='ROOT_PASSWORD=SecretPassword' \
  sameersbn/bind:latest

note that you cloud pull the image first with podman pull but I don't think it is necessary

The "--publish" flag that appears twice is for the web interface on port 10000 and for the DNS service on port 53, That is why I used two different IP's for them. You can also just leave it black without specifying an IP to make it accessible through all interfaces.

Now running podman ps should show us the running container with the name bind.

Accessing the web console

In the browser go to https://:10000 (in my case https://129.10.5.144:10000) Log in with root and SecretPassword

login

Now you can configure a new DNS zone!

Note

despite the link for the original tutorial being great I faced some issues creating a new zone. the problem was adding ns.example.com as the Master server when creating the new master zone, of course I changed it to my domain but it only worked when I changed it to one of the other default master zones like localhost. I used

podman exec -it bind bash

to enter the container and then

named-checkconf -zj

to check if the new zone was added successfully.

you should also check the logs with

podman logs bind
⚠️ **GitHub.com Fallback** ⚠️