Cgroups
v1 vs v2
Section titled “v1 vs v2”Linux has two cgroup implementations. rustbox supports both and auto-detects:
/sys/fs/cgroup/cgroup.controllersexists → v2/sys/fs/cgroup/memoryexists → v1- Neither → no cgroup support (permissive mode only)
The selection is logged so you always know which backend is active.
Docker compatibility
Section titled “Docker compatibility”Inside Docker, cgroup access is restricted:
- Probe before use. We test writability, never assume.
- Permissive fallback. Can’t create a cgroup? Warn and continue. Seccomp and namespaces still work.
- Strict mode fails. No cgroups + strict mode = rejected execution.
Resource enforcement
Section titled “Resource enforcement”| Resource | v2 | v1 |
|---|---|---|
| Memory | memory.max | memory.limit_in_bytes |
| CPU | cpu.max (quota/period) | cpu.cfs_quota_us |
| Processes | pids.max | pids.max |
| OOM detection | memory.events | memory.oom_control |
| CPU usage | cpu.stat (usage_usec) | cpuacct.usage |
| Memory peak | memory.peak | memory.max_usage_in_bytes |
Instance isolation
Section titled “Instance isolation”Each sandbox gets its own cgroup with a sanitised instance ID. Path traversal characters in instance IDs are rejected. On cleanup, all processes in the cgroup are killed before removal.