Docker不能从BIND服务器parsingDNS

我正在尝试使用Docker容器作为本地DNS服务器来重写专用networking中的现有域的IP。

我的设置是我有一个私人networking,有一些机器和一个路由器,有一个互联网可访问的公共IP。 其中一台机器通过将一个端口从路由器路由到它,在一个指向公共IP的域(比如example.com)上向互联网提供一些内容。 关键是私有networking中的其他机器也需要访问该服务器。 然而,路由器阻止来自内部的数据包访问公共IP。 所以我想我会使用这个容器作为本地DNS服务器来覆盖与本地的公共IP。

总之这是networking:

  • Ubuntu IP地址为192.168.1.6〜> docker主机
  • 用于IP地址为192.168.1.4〜>的主机
  • 其他IP地址范围为192.168.1.0/8的机器
  • 所有机器的DNS服务器设置为192.168.1.6

现在使用这个组合文件来设置BIND:

version: '2' services: bind: image: sameersbn/bind:latest restart: always dns: 8.8.8.8 logging: driver: "json-file" options: max-size: "200k" max-file: "10" environment: - ROOT_PASSWORD=somepass ports: - 10000:10000 - 53:53/udp volumes: - ./data:/data 

并有这个configuration:

 acl localclients { 192.168.0.0/16; 172.17.0.0/16; 172.23.0.0/16; localhost; localnets; }; options { directory "/var/cache/bind"; dnssec-validation auto; auth-nxdomain no; listen-on-v6 { any; }; listen-on { any; }; recursion yes; allow-query { any; }; allow-recursion { localclients; }; allow-query-cache { localclients; }; } 

目前在docker的主机(IP 192.168.1.6)上查找域名以及同一networking上的其他机器(IP 192.168.1.x)按预期工作:

 $ nslookup example.com Server: 192.168.1.6 Address: 192.168.1.64#53 Name: example.com Address: 192.168.1.4 

但我不能在另一个容器中使用它:

 $ docker run --rm busybox nslookup example.com Server: 192.168.1.6 Address 1: 192.168.1.6 servername Name: example.com Address 1: 188.15.221.88 

当我强制使用本地DNS服务器时,我得到以下输出

 $ docker run --rm --dns 192.168.1.6 busybox nslookup example.com nslookup: can't resolve 'example.com' Server: 192.168.1.6 Address 1: 192.168.1.6 

我不知道这是docker问题还是绑定configuration。

那么这不是一个答案,而是我find的解决方法,所以我不会把它标记为答案。

我找不到任何解决scheme,也许这是一个docker错误,也许(奇怪)所需的function。 然而,因为我真的需要find一个解决scheme,我使用了--add-host来运行命令和extra-hosts来编写文件来解决这个问题。