forked from mirrors/nixpkgs
Merge pull request #36352 from nlewo/pr-onTopOfPulledImage
Add dockerTools test: on top of pulled image
This commit is contained in:
commit
a682ba23d4
|
@ -10,7 +10,7 @@ import ./make-test.nix ({ pkgs, ... }: {
|
|||
docker =
|
||||
{ config, pkgs, ... }: {
|
||||
virtualisation = {
|
||||
diskSize = 1024;
|
||||
diskSize = 2048;
|
||||
docker.enable = true;
|
||||
};
|
||||
};
|
||||
|
@ -21,19 +21,29 @@ import ./make-test.nix ({ pkgs, ... }: {
|
|||
$docker->waitForUnit("sockets.target");
|
||||
|
||||
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.bash}'");
|
||||
$docker->succeed("docker run ${pkgs.dockerTools.examples.bash.imageName} /bin/bash --version");
|
||||
$docker->succeed("docker run --rm ${pkgs.dockerTools.examples.bash.imageName} /bin/bash --version");
|
||||
$docker->succeed("docker rmi ${pkgs.dockerTools.examples.bash.imageName}");
|
||||
|
||||
# Check if the nix store is correctly initialized by listing dependencies of the installed Nix binary
|
||||
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.nix}'");
|
||||
$docker->succeed("docker run ${pkgs.dockerTools.examples.nix.imageName} /bin/nix-store -qR ${pkgs.nix}");
|
||||
$docker->succeed("docker run --rm ${pkgs.dockerTools.examples.nix.imageName} /bin/nix-store -qR ${pkgs.nix}");
|
||||
$docker->succeed("docker rmi ${pkgs.dockerTools.examples.nix.imageName}");
|
||||
|
||||
# To test the pullImage tool
|
||||
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.nixFromDockerHub}'");
|
||||
$docker->succeed("docker run nixos/nix:1.11 nix-store --version");
|
||||
$docker->succeed("docker run --rm nixos/nix:1.11 nix-store --version");
|
||||
$docker->succeed("docker rmi nixos/nix:1.11");
|
||||
|
||||
# To test runAsRoot and entry point
|
||||
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.nginx}'");
|
||||
$docker->succeed("docker run --name nginx -d -p 8000:80 ${pkgs.dockerTools.examples.nginx.imageName}");
|
||||
$docker->waitUntilSucceeds('curl http://localhost:8000/');
|
||||
$docker->succeed("docker rm --force nginx");
|
||||
$docker->succeed("docker rmi '${pkgs.dockerTools.examples.nginx.imageName}'");
|
||||
|
||||
# An pulled image can be used as base image
|
||||
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.onTopOfPulledImage}'");
|
||||
$docker->succeed("docker run --rm ontopofpulledimage hello");
|
||||
$docker->succeed("docker rmi ontopofpulledimage");
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -116,4 +116,12 @@ rec {
|
|||
Env = [ "NIX_PAGER=cat" ];
|
||||
};
|
||||
};
|
||||
|
||||
# 7. example of adding something on top of an image pull by our
|
||||
# dockerTools chain.
|
||||
onTopOfPulledImage = buildImage {
|
||||
name = "onTopOfPulledImage";
|
||||
fromImage = nixFromDockerHub;
|
||||
contents = [ pkgs.hello ];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue