Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker does not respect hosts file #82

Closed
fooker opened this issue Oct 5, 2017 · 5 comments
Closed

Docker does not respect hosts file #82

fooker opened this issue Oct 5, 2017 · 5 comments

Comments

@fooker
Copy link

fooker commented Oct 5, 2017

The static docker binary uses the DNS server specified /etc/resolv.conf without consulting /etc/hosts beforehand. The image should contain a /etc/nsswitch.conf containing some minimal configuration which is used by the docker binary.

@tianon
Copy link
Member

tianon commented Oct 5, 2017

I believe this is a duplicate of #40.

@fooker
Copy link
Author

fooker commented Oct 6, 2017

Not sure. If I add the nsswitch.conf with some minimal content like below, it starts working.

hosts: files dns

@fooker
Copy link
Author

fooker commented Oct 6, 2017

After reading this again, I don't think this is a strict duplicate. Wether or not the native go dns implementation is used or not, in both cases, a nsswitch.conf should be provided. The native go implementation also supports a limited version of the file and must be configured to respect /etc/hosts (see https://github.com/golang/go/blob/4bd95702dd1e81f383ee67c14945620d30247908/src/net/conf.go#L198).

@tianon
Copy link
Member

tianon commented Oct 11, 2017

Huh, good point -- thinking/looking at it more, I think I like this solution better than that one, since it's adding a general config for DNS lookups rather than a debugging environment variable specifically to try and control Go's behavior (and in a way that's contrary to how upstream intentionally compiled said binary).

Looking a little further down in that same file at https://github.com/golang/go/blob/4bd95702dd1e81f383ee67c14945620d30247908/src/net/conf.go#L219-L253, it appears the only things supported by the netgo implementation are myhostname, files, dns, and mdns* (and then only *.local).

Looking at Debian's default file, it's got hosts: files dns, so I think that's probably what we ought to stick with (perhaps linking to all these resources from a comment). I'll work up a PR and have something ready to look at/test shortly. 👍

@tianon
Copy link
Member

tianon commented Oct 11, 2017

#84 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants