nixos/podman: Add rootless containers to test
This commit is contained in:
parent
ea9b5c5faa
commit
67a61fbd34
@ -10,21 +10,51 @@ import ./make-test-python.nix (
|
|||||||
nodes = {
|
nodes = {
|
||||||
podman =
|
podman =
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
virtualisation.podman.enable = true;
|
virtualisation.podman.enable = true;
|
||||||
|
virtualisation.containers.users = [
|
||||||
|
"alice"
|
||||||
|
];
|
||||||
|
|
||||||
|
users.users.alice = {
|
||||||
|
isNormalUser = true;
|
||||||
|
home = "/home/alice";
|
||||||
|
description = "Alice Foobar";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
start_all()
|
import shlex
|
||||||
|
|
||||||
|
|
||||||
|
def su_cmd(cmd):
|
||||||
|
cmd = shlex.quote(cmd)
|
||||||
|
return f"su alice -l -c {cmd}"
|
||||||
|
|
||||||
|
|
||||||
podman.wait_for_unit("sockets.target")
|
podman.wait_for_unit("sockets.target")
|
||||||
podman.succeed("tar cv --files-from /dev/null | podman import - scratchimg")
|
start_all()
|
||||||
podman.succeed(
|
|
||||||
"podman run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10"
|
|
||||||
)
|
with subtest("Run container as root"):
|
||||||
podman.succeed("podman ps | grep sleeping")
|
podman.succeed("tar cv --files-from /dev/null | podman import - scratchimg")
|
||||||
podman.succeed("podman stop sleeping")
|
podman.succeed(
|
||||||
|
"podman run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10"
|
||||||
|
)
|
||||||
|
podman.succeed("podman ps | grep sleeping")
|
||||||
|
podman.succeed("podman stop sleeping")
|
||||||
|
|
||||||
|
with subtest("Run container rootless"):
|
||||||
|
podman.succeed(su_cmd("tar cv --files-from /dev/null | podman import - scratchimg"))
|
||||||
|
podman.succeed(
|
||||||
|
su_cmd(
|
||||||
|
"podman run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
podman.succeed(su_cmd("podman ps | grep sleeping"))
|
||||||
|
podman.succeed(su_cmd("podman stop sleeping"))
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user