mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 13:57:10 +03:00
nixos/tests/docker-tools: check layer sharing with buildLayeredImage
Adapted from grahamc's blog post on layered Docker images in Nix: https://grahamc.com/blog/nix-and-layered-docker-images
This commit is contained in:
parent
7e6756af41
commit
3b0d5b5ed3
@ -68,6 +68,12 @@ import ./make-test.nix ({ pkgs, ... }: {
|
||||
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.layered-on-top}'");
|
||||
$docker->succeed("docker run --rm ${pkgs.dockerTools.examples.layered-on-top.imageName}");
|
||||
|
||||
# Ensure layers are shared between images
|
||||
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.another-layered-image}'");
|
||||
$docker->succeed("docker inspect ${pkgs.dockerTools.examples.layered-image.imageName} | ${pkgs.jq}/bin/jq -r '.[] | .RootFS.Layers | .[]' | sort > layers1.sha256");
|
||||
$docker->succeed("docker inspect ${pkgs.dockerTools.examples.another-layered-image.imageName} | ${pkgs.jq}/bin/jq -r '.[] | .RootFS.Layers | .[]' | sort > layers2.sha256");
|
||||
$docker->succeed('[ $(comm -1 -2 layers1.sha256 layers2.sha256 | wc -l) -ne 0 ]');
|
||||
|
||||
# Ensure order of layers is correct
|
||||
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.layersOrder}'");
|
||||
$docker->succeed("docker run --rm ${pkgs.dockerTools.examples.layersOrder.imageName} cat /tmp/layer1 | grep -q layer1");
|
||||
|
@ -226,4 +226,12 @@ rec {
|
||||
'';
|
||||
};
|
||||
|
||||
# 14. Create another layered image, for comparing layers with image 10.
|
||||
another-layered-image = pkgs.dockerTools.buildLayeredImage {
|
||||
name = "another-layered-image";
|
||||
tag = "latest";
|
||||
config.Cmd = [ "${pkgs.hello}/bin/hello" ];
|
||||
contents = [ pkgs.hello ];
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user