mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
nixos/modules/virtualisation: additional configuration options (#349537)
oci-containers: additional configuration options
This commit is contained in:
parent
51e98f6c79
commit
04bf3d8774
2 changed files with 297 additions and 154 deletions
|
@ -22,6 +22,16 @@ let
|
|||
image = "nginx-container";
|
||||
imageStream = pkgs.dockerTools.examples.nginxStream;
|
||||
ports = ["8181:80"];
|
||||
capAdd = {
|
||||
CAP_AUDIT_READ = true;
|
||||
};
|
||||
capDrop = {
|
||||
CAP_AUDIT_WRITE = true;
|
||||
};
|
||||
privileged = false;
|
||||
devices = [
|
||||
"/dev/random:/dev/random"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -32,11 +42,18 @@ let
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
import json
|
||||
|
||||
start_all()
|
||||
${backend}.wait_for_unit("${backend}-nginx.service")
|
||||
${backend}.wait_for_open_port(8181)
|
||||
${backend}.wait_until_succeeds("curl -f http://localhost:8181 | grep Hello")
|
||||
output = json.loads(${backend}.succeed("${backend} inspect nginx --format json").strip())[0]
|
||||
${backend}.succeed("systemctl stop ${backend}-nginx.service", timeout=10)
|
||||
assert output['HostConfig']['CapAdd'] == ["CAP_AUDIT_READ"]
|
||||
assert output['HostConfig']['CapDrop'] == ${if backend == "docker" then "[\"CAP_AUDIT_WRITE\"]" else "[]"} # Rootless podman runs with no capabilities so it cannot drop them
|
||||
assert output['HostConfig']['Privileged'] == False
|
||||
assert output['HostConfig']['Devices'] == [{'PathOnHost': '/dev/random', 'PathInContainer': '/dev/random', 'CgroupPermissions': '${if backend == "docker" then "rwm" else ""}'}]
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue