New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/dockerPreloader: preload docker images #49379
Conversation
4092e12
to
5582ec9
Compare
@GrahamcOfBorg test docker-preloader |
No attempt on aarch64-linux (full log) The following builds were skipped because they don't evaluate on aarch64-linux: tests.docker-preloader Partial log (click to expand)
|
No attempt on x86_64-linux (full log) The following builds were skipped because they don't evaluate on x86_64-linux: tests.docker-preloader Partial log (click to expand)
|
5582ec9
to
cc66b18
Compare
@GrahamcOfBorg test docker-preloader |
Success on aarch64-linux Attempted: tests.docker-preloader No partial log is available. |
Success on x86_64-linux (full log) Attempted: tests.docker-preloader Partial log (click to expand)
|
cc66b18
to
1f98898
Compare
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.
1f98898
to
21bd8c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice. It's adding a bit of complications but it will be useful in various scenarios.
# If docker.storageDriver is null, Docker choose the storage | ||
# driver. So, in this case, we cannot be sure overlay2 is used. | ||
assertion = cfg.dockerPreloader.images == [] | ||
|| cfg.docker.storageDriver == "overlay2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is "overlay2" not compatible with overlay2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is compatible. The assertion is true if the storageDriver is overlay2
.
|
||
$docker->waitForUnit("sockets.target"); | ||
$docker->succeed("docker run nix nix-store --version"); | ||
$docker->succeed("docker run bash bash --version"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we guaranteed that the VM won't access the network to fetch the image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. I don't think it's possible to disable remote registries in the Docker configuration. But this is guaranteed thanks to our sandbox.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful!
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.
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
canreplace the
services.kubernetes.kubelet.seedDockerImages
options.The idea is to populate the /var/lib/docker directory by mounting QCOW
files (we use QCOW files to avoid permission issues) that contain images.
For each image specified in
config.virtualisation.dockerPreloader.images:
This set of QCOW files can then be used to populate the
/var/lib/docker:
Motivation for this change
Speed up tests that require Docker images.
I have several Kubernetes tests that take more than 3min just to load Docker images (
seedDockerImages
k8s options). With this module, once QCOWs have been created, Docker images are immediately available in the test VMs (no more Docker load).Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)