-
Couldn't load subscription status.
- Fork 2.2k
Description
Any container can have sub-cgroups
- created by the container itself, if access is provided (cgroupns is enabled and cgroup mount is not readonly -- see examples for cgroup v1 and v2);
- created by some other tools (higher-level orchestrators, systemd, etc);
- created by runc itself (if a future runtime-spec will add an ability to define sub-cgroups and their resources).
This is a proposal to add a feature to have runc exec executed in a sub-cgroup of a container, rather than its top-level cgroup as it happens now (except for cgroup v2, which has a fallback to join container init's cgroup).
For example:
runc exec -d --cgroup /foo/bar CID cmd args...
will run cmd args inside container CID, putting cmd in container's foo/bar cgroup, relative to container's top-level cgroup.
Obviously, the default value for --cgroup is /, which is how it's working now.
In a similar manner, runtime-spec's Process structure need to add a Cgroup field with the same meaning as runc exec's --cgroup. For container init it doesn't make sense to have Cgroup set to any value other than /. For other execs, it can be changed.
One other implementation detail is, I guess runc exec --cgroup should NOT create the sub-cgroup if it does not exist, but return an error.