When /etc/resolv.conf contains nameserver 127.0.0.1, docker creates a custom resolv.conf in the container with the google name servers (8.8.8.8 and 8.8.4.4).
This is not always a good solution, as those name servers might not be reachable, or might not return the same records as the name server on 127.0.0.1 (#14627 is a more general purpose issue in regards to this issue). However when using --net=host this substitution is not necessary. When using --net=host, a name server listening on 127.0.0.1 is reachable from within the container.
# docker version
Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): linux/amd64
Server version: 1.7.0
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 0baf609
OS/Arch (server): linux/amd64
# docker info
Containers: 5
Images: 389
Storage Driver: btrfs
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.18.1-gentoo
Operating System: Gentoo/Linux
CPUs: 4
Total Memory: 7.512 GiB
Name: gadget
ID: KLI3:BPWQ:CK45:NJCL:ULCH:BV6Z:XDFM:YKTZ:EZ7D:UBE7:ZQCK:HOGN
Username: phemmer
Registry: https://index.docker.io/v1/
# cat /etc/resolv.conf
# Generated by NetworkManager
search citrite.net
nameserver 127.0.0.1
# docker run --rm --net=host ubuntu cat /etc/resolv.conf
# Generated by NetworkManager
search citrite.net
nameserver 8.8.8.8
nameserver 8.8.4.4
# docker run --rm --net=host ubuntu sh -c 'echo nameserver 127.0.0.1 > /etc/resolv.conf; getent ahosts google.com' 216.58.219.142 STREAM google.com
216.58.219.142 DGRAM
216.58.219.142 RAW
2607:f8b0:4008:808::200e STREAM
2607:f8b0:4008:808::200e DGRAM
2607:f8b0:4008:808::200e RAW
When
/etc/resolv.confcontainsnameserver 127.0.0.1, docker creates a customresolv.confin the container with the google name servers (8.8.8.8and8.8.4.4).This is not always a good solution, as those name servers might not be reachable, or might not return the same records as the name server on
127.0.0.1(#14627 is a more general purpose issue in regards to this issue). However when using--net=hostthis substitution is not necessary. When using--net=host, a name server listening on127.0.0.1is reachable from within the container.