3fb4eb1c43
This module permits to preload Docker image in a VM in order to reduce OIs on file copies. This module has to be only used in testing environments, when the test requires several Docker images such as in Kubernetes tests. In this case, `virtualisation.dockerPreloader.images` can replace the `services.kubernetes.kubelet.seedDockerImages` options. The idea is to populate the /var/lib/docker directory by mounting qcow files (we uses qcow file to avoid permission issues) that contain images. For each image specified in config.virtualisation.dockerPreloader.images: 1. The image is loaded by Docker in a VM 2. The resulting /var/lib/docker is written to a QCOW file This set of QCOW files can then be used to populate the /var/lib/docker: 1. Each QCOW is mounted in the VM 2. Symlink are created from these mount points to /var/lib/docker 3. A /var/lib/docker/image/overlay2/repositories.json file is generated 4. The docker daemon is started.
28 lines
805 B
Nix
28 lines
805 B
Nix
import ./make-test.nix ({ pkgs, ...} : {
|
|
name = "docker-preloader";
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
|
maintainers = [ lewo ];
|
|
};
|
|
|
|
nodes = {
|
|
docker =
|
|
{ pkgs, ... }:
|
|
{
|
|
virtualisation.docker.enable = true;
|
|
virtualisation.dockerPreloader.images = [ pkgs.dockerTools.examples.nix pkgs.dockerTools.examples.bash ];
|
|
|
|
services.openssh.enable = true;
|
|
services.openssh.permitRootLogin = "yes";
|
|
services.openssh.extraConfig = "PermitEmptyPasswords yes";
|
|
users.extraUsers.root.password = "";
|
|
};
|
|
};
|
|
testScript = ''
|
|
startAll;
|
|
|
|
$docker->waitForUnit("sockets.target");
|
|
$docker->succeed("docker run nix nix-store --version");
|
|
$docker->succeed("docker run bash bash --version");
|
|
'';
|
|
})
|