1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-21 05:00:16 +00:00

dockerTools.streamLayeredImage: Add test for fakeRootCommands

This commit is contained in:
vroad 2021-04-07 18:11:02 +09:00
parent c420e650c9
commit 63e7c4186f
2 changed files with 21 additions and 0 deletions

View file

@ -270,5 +270,13 @@ import ./make-test-python.nix ({ pkgs, ... }: {
docker.succeed(
"docker images --format '{{.Repository}}' | grep -F '${examples.prefixedLayeredImage.imageName}'"
)
with subtest("buildLayeredImage supports running chown with fakeRootCommands"):
docker.succeed(
"docker load --input='${examples.layeredImageWithFakeRootCommands}'"
)
docker.succeed(
"docker run --rm ${examples.layeredImageWithFakeRootCommands.imageName} sh -c 'stat -c '%u' /home/jane | grep -E ^1000$'"
)
'';
})

View file

@ -441,4 +441,17 @@ rec {
tag = "latest";
config.Cmd = [ "${pkgs.hello}/bin/hello" ];
};
# layered image with files owned by a user other than root
layeredImageWithFakeRootCommands = pkgs.dockerTools.buildLayeredImage {
name = "layered-image-with-fake-root-commands";
tag = "latest";
contents = [
pkgs.pkgsStatic.busybox
];
fakeRootCommands = ''
mkdir -p ./home/jane
chown 1000 ./home/jane
'';
};
}