2016-11-08 156 views
0

我尝试使用自定义网络和dos设置创建docker容器。Docker DNS设置

泊坞窗网创建--driver =桥--opt “com.docker.network.bridge.enable_ip_masquerade”= “真” --opt “com.docker.network.bridge.enable_icc”= “真” --opt = “com.docker.network.driver.mtu”= “1500” --opt = “com.docker.network.bridge.host_binding_ipv4”= “0.0.0.0” 净

-

搬运工运行--dns 10.0.0.2 --network =净busybox的猫的/etc/resolv.conf

域名服务器127.0.0.11 选项的ndots:0

不然,如果我使用标准的网络中的所有工作正常

搬运工运行--dns 10.0.0.2 --network =桥busybox的猫/等/ resolv.conf的

域名服务器10.0.0.2

回答

1

从Docker 1.10开始,对于用户定义的网络,DNS进行不同的管理。为了向后兼容,默认网桥网络的DNS不变。在用户定义的网络中,docker守护进程使用嵌入式DNS服务器。根据该文件在这里找到:

https://docs.docker.com/engine/userguide/networking/configure-dns/

--dns=[IP_ADDRESS...] The IP addresses passed via the --dns option is used by the embedded 
         DNS server to forward the DNS query if embedded DNS server is unable 
         to resolve a name resolution request from the containers. These 
         --dns IP addresses are managed by the embedded DNS server and will not 
         be updated in the container’s /etc/resolv.conf file. 

因此,DNS名称服务器将被使用,它只是没有在容器的/etc/resolv.conf中可见。

+0

使用此选项将nameserver的ip映射到容器的/etc/resolv.conf文件中。它在那里可见。 – MilesMcBain

+0

作为替代方案,您可以使用[此解决方案](https://github.com/mageddo/dns-proxy-server/),它是一个解析容器主机名的DNS服务器,也可以解决互联网上的地址问题 – deFreitas