2016-11-08 155 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