Skip to content

Conversation

@Jackong
Copy link

@Jackong Jackong commented Jan 7, 2016

No description provided.

@tianon
Copy link
Member

tianon commented Jun 16, 2016

Sorry for the delay, but can you elaborate a bit on what problem this is solving and why it's necessary/proper? It feels a little strange to be providing nsswitch.conf contents that differ from the default provided by our image base (and on top of that, Docker itself has moved away from using /etc/hosts and now hijacks DNS more directly, and Alpine 3.4 had several DNS-related fixes as well).

@ei-grad
Copy link

ei-grad commented Dec 13, 2016

It looks the way docker hijacks DNS doesn't work, and Golang does its awful deed on behance of GNU trolls, who claim to use DNS before FILES in case if nsswitch is missed. I spent a day trying to debug why a postgresql queries come sequential one by one. Burn in hell.

@ei-grad
Copy link

ei-grad commented Dec 13, 2016

Is there any way to run test like:

→ docker run -it --rm golang:alpine sh
Unable to find image 'golang:alpine' locally
alpine: Pulling from library/golang
3690ec4760f9: Already exists 
c311f66f3ac9: Already exists 
89656d2b09ac: Pull complete 
1602314b9bf7: Pull complete 
181529c471d2: Pull complete 
b561214ca853: Pull complete 
Digest: sha256:c502cbf4608374447cef87d493047ca1a33fc02c0a100f29fe186653881c4b25
Status: Downloaded newer image for golang:alpine
/go # cat > t.go << EOF
package main

import "net"

func main() {
    net.LookupHost("linked")
}
EOF
/go # GODEBUG=netdns=2 go run t.go 2>&1 | grep dns,files && echo "Burn in hell!"
go package net: hostLookupOrder(linked) = dns,files
Burn in hell!

@fredleger
Copy link

+1 for this. very anoying for us

@tianon
Copy link
Member

tianon commented Nov 4, 2017

I'm convinced -- if you'd like to rebase this to the current versions and update it to match what was implemented in docker-library/docker#84, that'd be great, otherwise I'll do so when I get a chance. 👍 ❤️

@tianon
Copy link
Member

tianon commented Nov 4, 2017

To be more specific:

# set up nsswitch.conf for Go's "netgo" implementation
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf

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

Successfully merging this pull request may close these issues.

4 participants