3

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

docker network create --driver=bridge --opt "com.docker.network.bridge.enable_ip_masquerade"="true" --opt "com.docker.network.bridge.enable_icc"="true" --opt="com .docker.network.driver.mtu"="1500" --opt="com.docker.network.bridge.host_binding_ipv4"="0.0.0.0" 网络

--

docker run --dns 10.0.0.2 --network=net busybox cat /etc/resolv.conf

名称服务器 127.0.0.11 选项 ndots:0

否则,如果我使用标准网络一切正常

docker run --dns 10.0.0.2 --network=bridge busybox cat /etc/resolv.conf

名称服务器 10.0.0.2

4

1 回答 1

5

从 Docker 1.10 开始,对于用户定义的网络,DNS 的管理方式有所不同。为了向后兼容,默认桥接网络的 DNS 保持不变。在用户定义的网络中,docker daemon 使用嵌入式 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 中不可见。

于 2016-11-09T19:11:40.370 回答