Docker DNS settings

情到浓时终转凉″ 提交于 2019-12-11 06:38:47

问题


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" net

--

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

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

nameserver 10.0.0.2


回答1:


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.

So, the DNS nameserver will be used, it just is not visible in the container's /etc/resolv.conf.



来源:https://stackoverflow.com/questions/40483053/docker-dns-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!