3
0
Fork 0
forked from mirrors/nixpkgs

dockerTools.buildImage: test that created=now makes an unstable date

This commit is contained in:
Graham Christensen 2018-09-20 13:02:22 -04:00
parent 3222fe1756
commit aedc651903
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
2 changed files with 16 additions and 0 deletions

View file

@ -20,7 +20,10 @@ import ./make-test.nix ({ pkgs, ... }: {
''
$docker->waitForUnit("sockets.target");
# Ensure Docker images use a stable date by default
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.bash}'");
$docker->succeed("[ '1970-01-01T00:00:01Z' = \"\$(docker inspect ${pkgs.dockerTools.examples.bash.imageName} | ${pkgs.jq}/bin/jq -r .[].Created)\" ]");
$docker->succeed("docker run --rm ${pkgs.dockerTools.examples.bash.imageName} bash --version");
$docker->succeed("docker rmi ${pkgs.dockerTools.examples.bash.imageName}");
@ -51,5 +54,9 @@ import ./make-test.nix ({ pkgs, ... }: {
$docker->succeed("docker run --rm runasrootextracommands cat extraCommands");
$docker->succeed("docker run --rm runasrootextracommands cat runAsRoot");
$docker->succeed("docker rmi '${pkgs.dockerTools.examples.runAsRootExtraCommands.imageName}'");
# Ensure Docker images can use an unstable date
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.bash}'");
$docker->succeed("[ '1970-01-01T00:00:01Z' != \"\$(docker inspect ${pkgs.dockerTools.examples.unstableDate.imageName} | ${pkgs.jq}/bin/jq -r .[].Created)\" ]");
'';
})

View file

@ -141,4 +141,13 @@ rec {
runAsRoot = ''echo "(runAsRoot)" > runAsRoot'';
extraCommands = ''echo "(extraCommand)" > extraCommands'';
};
# 9. Ensure that setting created to now results in a date which
# isn't the epoch + 1
unstableDate = pkgs.dockerTools.buildImage {
name = "unstable-date";
tag = "latest";
contents = [ pkgs.coreutils ];
created = "now";
};
}