Skip to content

Docker should not substitute 127.0.0.1 name server when using --net=host #15819

@phemmer

Description

@phemmer

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    

Metadata

Metadata

Assignees

Labels

area/networkingNetworkingpriority/P1Important: P1 issues are a top priority and a must-have for the next release.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions