caddyserver / caddy-docker

Source for the official Caddy v2 Docker Image
https://hub.docker.com/_/caddy
Apache License 2.0
405 stars 74 forks source link

Building custom image from caddy:2.6.2 failed #273

Closed nick-ge closed 1 year ago

nick-ge commented 1 year ago

Dear caddy-docker maintainer,

I've tried to build a custom image from your Alpine Dockerfile (caddy-docker/2.6/alpine/Dockerfile) with the following command:

docker build --tag <custom-tag> .

During the building process I encountered the following error message:

Step 6/18 : RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
 ---> Running in 3762efc54156
The command '/bin/sh -c [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf' returned a non-zero code: 1

I guess there might be a mistake since the test command checks if /etc/nsswitch.conf is not available and in case write to it. You probably mean to check whether /etc/nsswitch.conf is indeed available. So no exclamation mark in test command. I guess the RUN statement was supposed to look like the following:

RUN [ -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf

Correct me if I'm wrong or missing something.

Best regards!

abjugard commented 1 year ago

It looks like /etc/nsswitch.conf already contains the line hosts: files dns in the chosen alpine base image, so that line is unnecessary, and it's failing because the line returns false without an || statement, causing the build to fail.

I would just remove the line entirely as it doesn't seem necessary.

francislavoie commented 1 year ago

@abjugard thanks for pointing that out.

Looks like the nsswitch stuff was removed from the golang Docker image in https://github.com/docker-library/golang/commit/d66a926ed0c800594ce37c4c949ab4ece231c4af since it's no longer needed as you said.

@hairyhenderson I guess we should remove it from here now as well.