From f8031c60b72f26adeaa236abc3dabd52b94b4978 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 20 Aug 2021 19:44:17 +0200 Subject: [PATCH] dockerTools.fakeNss: add /etc/nsswitch.conf (#134958) Apparently, a non-existent nsswitch.conf causes a very misleading host resolution, differing from the defaults people are used to. According to https://github.com/golang/go/issues/22846#issuecomment-346377144, glibc says the default is "dns [!UNAVAIL=return] files". This means, `/etc/hosts` isn't really honored, causing all sorts of unexpected behaviour. Let's prevent this, and first ask `/etc/hosts` before querying DNS, like we do on NixOS too. --- pkgs/build-support/docker/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix index d76efac55b1a..832d2949a1aa 100644 --- a/pkgs/build-support/docker/default.nix +++ b/pkgs/build-support/docker/default.nix @@ -750,6 +750,9 @@ rec { root:x:0: nobody:x:65534: '') + (writeTextDir "etc/nsswitch.conf" '' + hosts: files dns + '') (runCommand "var-empty" { } '' mkdir -p $out/var/empty '')