我尝试使用自定义网络和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
nameserver 127.0.0.11 options ndots:0
否则,如果我使用标准网络,那么一切正常
docker run --dns 10.0.0.2 --network = bridge busybox cat /etc/resolv.conf
nameserver 10.0.0.2
答案 0 :(得分:2)
从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中不可见。