Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

create minimal nsswitch.conf file in Docker image #1630

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docker/Dockerfile.flux
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ ENTRYPOINT [ "/sbin/tini", "--", "fluxd" ]
COPY --from=quay.io/squaremo/kubeyaml:0.5.1 /usr/lib/kubeyaml /usr/lib/kubeyaml/
ENV PATH=/bin:/usr/bin:/usr/local/bin:/usr/lib/kubeyaml

# Create minimal nsswitch.conf file to prioritize the usage of /etc/hosts 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:
# https://github.com/golang/go/issues/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:
# https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-354316460
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would write out the entire file as it is, and make this a COPY ./nsswitch.conf /etc/nsswitch.conf. Given the context, I doubt it would eventually appear in the Alpine image.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point; on the other hand it doesn't hurt to be careful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho the current one-liner is great; I doubt we will ever make changes to the nsswitch.conf content so there is no reason to maintain a separate file to ease modifications.

COPY ./kubeconfig /root/.kube/config
COPY ./fluxd /usr/local/bin/

Expand Down