-
Notifications
You must be signed in to change notification settings - Fork 620
Force cgo for golang DNS resolver #40
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
Conversation
The default behavior of the golang net package is to use the pure go implementation which sends DNS requests directly to the servers listed in resolv.conf. This breaks when running the docker client inside a docker container that's 'linked' with other containers given that those links utilize teh /etc/hosts to function. This change forces golang's netdns to use cgo which uses the system c libraries and respects nsswitch. Before this change any short name conflict will result in the DNS query resolving to a remote host instead of the linked container. For example, docker will resolve to docker.rc.fas.harvard.edu instead of the linked container due to the search domain in /etc/resolv.conf.
|
I should also note this is documented at golang.org |
|
Aren't Docker's official release binaries explicitly compiled with IMO it might be better to instead document adding |
|
I didn't see where the Docker official release binaries are compiled with My argument against documentation is, using I also wrestled with sending this upstream but found some arguments about similar go applications which asserted that this was a problem with the application or language and could be solved other ways. I settle on putting it here because it minimized the impact of the change but I'm totally open to sending this upstream. |
|
IMHO golang should provide from: https://golang.org/src/net/net.go Also the docs claim it will switch to cgo under a variety of circumstances including if I think this is a worthwhile change unless there's a really compelling reason not to rely on the system C libraries for dns lookups. It's a good question whether docker upstream should also force cgo... |
|
It looks like |
|
See #84, which adds an appropriate |
|
Awesome! |
The default behavior of the golang net package is to use the pure go
implementation which sends DNS requests directly to the servers listed
in resolv.conf. This breaks when running the docker client inside a
docker container that's 'linked' with other containers given that those
links utilize teh /etc/hosts to function. This change forces golang's
netdns to use cgo which uses the system c libraries and respects
nsswitch.
Before this change any short name conflict will result in the DNS query
resolving to a remote host instead of the linked container. For
example, docker will resolve to docker.rc.fas.harvard.edu instead of
the linked container due to the search domain in /etc/resolv.conf.