Skip to main content
  1. Posts/

Bind DNS on Docker

·3 mins·
Table of Contents

I thought I share my little write-up (for future-me, or anyone finding it useful) how to set up a simple DNS server painlessly.

The situation #

Currently I have my main domain (a media server, that I expose via NAT and protect with OAuth2), and my secondary domain, which I currently use for my internal kubernetes cluster. This later one I want to have it available only on my internal network for the time being – but ideally I would not want to modify the hosts files of my various systems to access its services. So I just deployed my Bind9 server.

  • I am not claiming full credit for the idea, as it heavily inspired by the work of Christian Lempa‘s video tutorial
  • my repo with some basic notes (also I added the Ansible-parts to extend Christian’s work)

The process #

  1. Firstly I have created a Ubuntu 20.04 container on my Proxmox server, with the IP of 10.0.0.9 (I do not go into too many details, the process is very straightforward; one can use full-blown Ubuntu as well if he likes)
  2. Once the container was up and connectable, I installed Ansible on this (details are in the repo’s readme)
  3. Next, I prepared a playbook – see it in the playbooks folder – to disable the DNS server. This is actually not needed for the container – I believe the LXC does not run this service – but needed if you install full Ubuntu.
  4. As the last Ansible action, I have run the second playbook, which will install Docker and Docker compose.
  5. The last step has two parts: a. Edit the named.conf, docker-compose.yml and your zone file(s) to reflect your setup b. run docker-compose up -d && docker ps from the /bind9/docker-compose directory

Test #

image1

Once bind is running on the server, you can test it from a remote machine

The result from the DNS server should confirm resolution – in this case via forwarders – is working.

The local domain – which I have declared via the zone file – should be also resolvable via the Bind server, as opposed to Google’s DNS server, which is not aware.

image2

Finally, the last step of implementation is to set your DHCP server (or, set it manually, if your host has a manual configuration) to use this server for DNS resolution.

image3

I am also considering adding this service to a Kubernetes cluster, but for the time being my cluster is mostly for learning/experimenting only, so I prefer to have this in a separate environment. I might revisit this in the future.