nixos/dockerTools: fix includeStorePaths when enableFakechroot

After #268458, when setting `enableFakechroot = true` and
`includeStorePaths = false`, some of the store paths were getting
included into the image anyway, thru `bind-paths`.
This resulted in unexpectedly large images.

Now, the images will not contain any store paths under those
circumstances.
This commit is contained in:
Robert K. Bell 2023-12-04 14:39:18 +11:00
parent 0eb6d4fb0c
commit 8353fad13d
No known key found for this signature in database
GPG Key ID: 8A68AF21E4E214E2
3 changed files with 4 additions and 0 deletions

View File

@ -75,6 +75,8 @@ in {
docker.succeed("${examples.helloOnRootNoStore} | docker load")
docker.fail("docker run --rm hello | grep -i hello")
docker.succeed("docker image rm hello:latest")
with subtest("Ensure ZERO paths are added to the store"):
docker.fail("${examples.helloOnRootNoStore} | ${pkgs.crane}/bin/crane export - - | tar t | grep 'nix/store/'")
with subtest("includeStorePath = false; works with mounted store"):
docker.succeed("${examples.helloOnRootNoStore} | docker load")
docker.succeed("docker run --rm --volume ${builtins.storeDir}:${builtins.storeDir}:ro hello | grep -i hello")

View File

@ -922,6 +922,7 @@ rec {
--sort name \
--exclude=./proc \
--exclude=./sys \
--exclude=.${builtins.storeDir} \
--numeric-owner --mtime "@$SOURCE_DATE_EPOCH" \
--hard-dereference \
-cf $out/layer.tar .

View File

@ -637,6 +637,7 @@ rec {
];
config.Cmd = [ "hello" ];
includeStorePaths = false;
enableFakechroot = true;
};
etc =