dockerTools.fakeNss: init
This provides a /etc/passwd and /etc/group that contain root and nobody. Useful when packaging binaries that insist on using nss to look up username/groups (like nginx). The current nginx example used the `runAsRoot` parameter to setup /etc/group and /etc/passwd (which also doesn't exist in buildLayeredImage), so we can now just use fakeNss there and use buildLayeredImage.
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
writeReferencesToFile,
|
||||
writeScript,
|
||||
writeText,
|
||||
writeTextDir,
|
||||
writePython3,
|
||||
system, # Note: This is the cross system we're compiling for
|
||||
}:
|
||||
@@ -70,7 +71,7 @@ in
|
||||
rec {
|
||||
|
||||
examples = callPackage ./examples.nix {
|
||||
inherit buildImage pullImage shadowSetup buildImageWithNixDb;
|
||||
inherit buildImage buildLayeredImage fakeNss pullImage shadowSetup buildImageWithNixDb;
|
||||
};
|
||||
|
||||
pullImage = let
|
||||
@@ -684,6 +685,26 @@ rec {
|
||||
in
|
||||
result;
|
||||
|
||||
# Provide a /etc/passwd and /etc/group that contain root and nobody.
|
||||
# Useful when packaging binaries that insist on using nss to look up
|
||||
# username/groups (like nginx).
|
||||
fakeNss = symlinkJoin {
|
||||
name = "fake-nss";
|
||||
paths = [
|
||||
(writeTextDir "etc/passwd" ''
|
||||
root:x:0:0:root user:/var/empty:/bin/sh
|
||||
nobody:x:65534:65534:nobody:/var/empty:/bin/sh
|
||||
'')
|
||||
(writeTextDir "etc/group" ''
|
||||
root:x:0:
|
||||
nobody:x:65534:
|
||||
'')
|
||||
(runCommand "var-empty" {} ''
|
||||
mkdir -p $out/var/empty
|
||||
'')
|
||||
];
|
||||
};
|
||||
|
||||
# Build an image and populate its nix database with the provided
|
||||
# contents. The main purpose is to be able to use nix commands in
|
||||
# the container.
|
||||
|
||||
Reference in New Issue
Block a user