Last Updated: 2/16/2025
THIS IS IN PROGRESS
We are going to talk about starting a docker container for the sole purpose of acting as a DNS resolver. Largely as redundant task as so many of our devices [routers, etc] already have DNS working for us.
Example: if your docker host is 192.168.160.72 and we want to create the container using a static IP say 192.168.160.51 well then we have our work cut out for us.
Please remember that that our premise is what it making our own lives a little more difficult then needs to happen. If we had simply made use of a separate network this whole process would be a lot simpler because our host could have kept track of were to throw the traffic for the subnets. But that is NOT what this example covers. We are taking the road less travelled.
As an aside: we are going to start out with a number of asides: and if you don’t need the following information then you are having a good day. IF for some reason in your working with docker networking you loose the ability for the terminal to echo characters back you can:
stty sane
As an aside: The os for the BIND9 container is
root@25e287ecc246:/etc# cat os-release
PRETTY_NAME="Ubuntu 24.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.1 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
We are going to start with a basic docker-compose.yaml file:
services:
bind9:
container_name: bind9-dns
image: ubuntu/bind9:latest
environment:
- BIND9_USER=root
- TZ=America/New_York
ports:
- "53:53/tcp"
- "53:53/udp"
volumes:
- ./config:/etc/bind
- ./cache:/var/cache/bind
- ./records:/var/lib/bind
restart: unless-stopped
networks:
bind9-net:
ipv4_address: 192.168.160.51
networks:
bind9-net:
driver: bridge
ipam:
config:
- subnet: 192.168.160.0/24
gateway: 192.168.160.254
Aside: This is purely information… unless it isn’t.. It might be the case you need to free up the use of port 53 on the host machine you are on.
If you are running the systemd-resolver…. then port 53 is already going to be in use. You might temporarily (or not) need to make the decision to remove that.
sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved
To re-enable
sudo systemctl enable systemd-resolved
sudo systemctl start systemd-resolved
notes:
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-caching-or-forwarding-dns-server-on-ubuntu-14-04
https://medium.com/@jonezy7173_88832/setting-up-bind-dns-for-your-homelab-using-docker-d9fd3ae8e547