Docker DNS设置 [英] Docker DNS settings
问题描述
我尝试使用自定义网络和dos设置创建docker容器。
I try create docker container with custom network and dos settings.
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 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" net
-
docker run --dns 10.0.0.2 --network = net busybox cat /etc/resolv.conf
docker run --dns 10.0.0.2 --network=net busybox cat /etc/resolv.conf
名称服务器127.0。 0.11
选项ndots:0
nameserver 127.0.0.11 options ndots:0
否则,如果我使用标准网络,一切都可以正常工作
Else if I use standard network all work fine
docker run --dns 10.0.0.2 --network = bridge busybox cat /etc/resolv.conf
docker run --dns 10.0.0.2 --network=bridge busybox cat /etc/resolv.conf
名称服务器10.0.0.2
nameserver 10.0.0.2
推荐答案
从Docker 1.10开始,对于用户定义的网络,DNS的管理方式有所不同。默认桥网络的DNS保持不变,以实现向后兼容。在用户定义的网络中,泊坞窗守护程序使用嵌入式DNS服务器。根据此处找到的文档:
As of Docker 1.10, DNS is managed differently for user-defined networks. DNS for the default bridge network is unchanged for backwards compatibility. In a user-defined network, docker daemon uses the embedded DNS server. According to the documentation found here:
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。
So, the DNS nameserver will be used, it just is not visible in the container's /etc/resolv.conf.
这篇关于Docker DNS设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!