Docker DNS 设置
Docker DNS settings
我尝试使用自定义网络和 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" net
--
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
从 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.
中不可见
我尝试使用自定义网络和 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" net
--
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
从 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.
中不可见