1 # This test runs docker and checks if simple container starts
3 import ./make-test-python.nix ({ lib, pkgs, ...} : {
4 name = "docker-rootless";
5 meta = with pkgs.lib.maintainers; {
6 maintainers = [ abbradar ];
10 machine = { pkgs, ... }: {
11 virtualisation.docker.rootless.enable = true;
20 testScript = { nodes, ... }:
22 user = nodes.machine.config.users.users.alice;
23 sudo = lib.concatStringsSep " " [
24 "XDG_RUNTIME_DIR=/run/user/${toString user.uid}"
25 "DOCKER_HOST=unix:///run/user/${toString user.uid}/docker.sock"
26 "sudo" "--preserve-env=XDG_RUNTIME_DIR,DOCKER_HOST" "-u" "alice"
29 machine.wait_for_unit("multi-user.target")
31 machine.succeed("loginctl enable-linger alice")
32 machine.wait_until_succeeds("${sudo} systemctl --user is-active docker.service")
34 machine.succeed("tar cv --files-from /dev/null | ${sudo} docker import - scratchimg")
36 "${sudo} docker run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10"
38 machine.succeed("${sudo} docker ps | grep sleeping")
39 machine.succeed("${sudo} docker stop sleeping")