docker-library / golang

Docker Official Image packaging for golang
https://golang.org
BSD 3-Clause "New" or "Revised" License
1.48k stars 512 forks source link

Fail to set up nsswitch.conf #436

Closed shunjikonishi closed 2 years ago

shunjikonishi commented 2 years ago

I've copied this Dockerfile and customizing. It worked last week. However it failed today on this line.

https://github.com/docker-library/golang/blob/master/1.19/alpine3.16/Dockerfile#L14

It seems that now alpine docker image has /etc/nsswitch.conf file.

If tha file dones't exist, it works. However if it exist, test returns 1 and stop.

tianon commented 2 years ago

I can't seem to reproduce?

$ docker run --rm --pull=always alpine:3.16 ls -l /etc/nsswitch.conf
3.16: Pulling from library/alpine
213ec9aee27d: Already exists 
Digest: sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad
Status: Downloaded newer image for alpine:3.16
ls: /etc/nsswitch.conf: No such file or directory
shunjikonishi commented 2 years ago

hmm, I've verified that. To be honest, my image is not FROM alpine:3.16. That uses from other my docker image(Delived from alpine:3.16) and then run full copy of this file. nsswitch.conf might be created by other previous process.

However I think the potential problem is still remain. If nsswitch.conf exists, build failed.

Probably you can reproduce by RUN touch /etc/nsswitch.conf

tianon commented 2 years ago

If nsswitch.conf exists, build failed.

This is entirely by design (the line was written specifically to do exactly that). It's unexpected for FROM alpine:3.16 to contain this file, so we verify that it doesn't exist before we overwrite it. If you're copying our Dockerfile to build in a different environment, you're going to have to also adjust it for things like this (that's unfortunately not a use case we directly support).

shunjikonishi commented 2 years ago

I see. I've misunderstood your intention. I thought the test means, if nsswitch.conf exists, skip to creater that file.

Thanks.