-
Notifications
You must be signed in to change notification settings - Fork 529
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
Alpine linux doesn't have nsswitch configuration file #367
Comments
We're facing this too. I noticed that our pods in Kubernetes were making DNS calls for |
same issue |
The only place we've seen issues with this in the official images is in Go-based binaries (since Go itself uses What I'm not clear on is whether there are other bits of software in Alpine that aren't using Go which read this file? In digging for docker-library/docker#84, I noticed that Alpine had |
@tianon |
Hello @tianon , I tested Python in alpine, and Python do read I'm not sure missing What do you think? |
As @tianon mentions and as commented here: docker-library/docker#82 (comment) it is Go that is hardcoded to behave as glibc (dns first and then use hosts if it fails) if there is no |
@ncopa got that |
Does this need a bug/enhancement request in Golang? |
Helo @thaJeztah I'm really Sorry about the delay reply... I'm not sure whether it is a bug because we can not create a |
Well, mainly was looking at;
Wondering if that needs a solution / should be customisable |
Isn't GO one of the main reasons to use Alpine , especially in Kubernetes ? I end up with hundreds of request in my dns for "localhost.(Any Number of search domains)" |
The simplest workaround is to create for yourself a trivial one-line # 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 |
As a result, /etc/hosts will be prioritized over DNS queries This resolves the conflict between: * fluxd using netgo for static compilation. netgo reads nsswitch.conf to mimic glibc, defaulting to prioritize DNS queries over /etc/hosts if nsswitch.conf is missing: golang/go#22846 * Alpine not including a nsswitch.conf file. Since Alpine doesn't use glibc (it uses musl), maintainers argue that the need of nsswitch.conf is a Go bug: gliderlabs/docker-alpine#367 (comment)
A potential Go fix would be to implement https://tools.ietf.org/html/draft-ietf-dnsop-let-localhost-be-localhost-02 |
Due to this error, the program running based it will never resolve hosts via
/etc/hosts
but always use DNS.Users using alpine as their based image should always add an extra
nsswitch.conf
to it, I think it's not very friendly and we should add the configuration file by default.The text was updated successfully, but these errors were encountered: