Docker Community Forums

Share and learn in the Docker community.

Docker Bind9 Unable To Resolve From Outside Container

I’m trying to move a Bind9 configuration into a Docker Container. The Docker Container is primarily running Bind9 and Apache2 (just to test). Both in a single container with Supervisor.

The Apache2 Host is configured as

<VirtualHost *:80>
   ServerName defaultweb.dnsserver.lan
   ServerAlias www.defaultweb.dnsserver.lan
   DocumentRoot /var/www/html/public_html/defaultweb
   <Directory "/var/www/html/public_html/defaultweb">
      Options FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory>
</VirtualHost>

And the Bind9 configurations are as follows

named.conf.local

zone "dnsserver.lan" {
        type master;
        file "/etc/bind/zones/db.dnsserver.lan";
};

named.conf.options

options {
        directory "/var/cache/bind";
        recursion yes;
        listen-on { any; };
        forwarders { 8.8.8.8; 8.8.4.4; };
};

db.deb10serv.lan

$TTL    604800
@       IN      SOA     dnsserver.lan. admin.dnsserver.lan. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
@       IN      NS      ns1.deb10serv.lan.
@       IN      NS      ns2.deb10serv.lan.
ns1.dnsserver.lan.      IN      A       10.1.2.30
ns2.dnsserver.lan.      IN      A       10.1.2.30
host.dnsserver.lan.     IN      A       10.1.2.30
defaultweb.dnsserver.lan.        IN      A       10.1.2.30

I’m starting the container with

docker run -d -p 53:53/udp -p 80:80 --add-host defaultweb.dnsserver.lan:10.1.2.30 --hostname dnsserver --name dnsserver dnsserver

Then connecting it to an existing docker network with

docker network connect --ip 10.1.2.30 container_network dnsserver

I can access Apache2 just fine from another machine using the host machines IP (192.168.69.69) and added the same IP as the Primary DNS on the machine I’m testing from. I can also access the DNS name from inside of the container

> ping defaultweb.dnsserver.lan
PING defaultweb.dnsserver.lan (10.1.2.30) 56(84) bytes of data.
64 bytes from defaultweb.dnsserver.lan (10.1.2.30): icmp_seq=1 ttl=64 time=0.029 ms

When I try to access Apache2 from another machine with the DNS name though (defaultweb.dnsserver.lan) it fails with the following message

> ping defaultweb.dnsserver.lan
Pinging defaultweb.dnsserver.lan [10.1.2.30] with 32 bytes of data:
Reply from 100.116.46.139: Destination host unreachable.

But it is recognizing the IP as 10.1.2.30

Any assistance with this would be a huge help!