Skip to content

fix(compose): support cgroup_parent and cgroup service fields - #5230

Merged
AkihiroSuda merged 1 commit into
containerd:mainfrom
invenconlabs:fix/compose-cgroup-parent
Oct 2, 2026
Merged

AkihiroSuda merged 1 commit into
containerd:mainfrom
invenconlabs:fix/compose-cgroup-parent

Conversation

@addemod

@addemod addemod commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

nerdctl compose ignores the cgroup_parent and cgroup service fields, which nerdctl run supports as --cgroup-parent and --cgroupns:

services:
  probe:
    image: alpine
    cgroup_parent: foo.slice
level=warning msg="Ignoring: service probe: [CgroupParent]"

The service still starts, in the default cgroup parent. cgroup: host is dropped the same way and the container keeps a private cgroup namespace. For cgroup_parent that means the container runs outside the resource limits the parent was meant to apply, with only a warning.

Cause

compose-go loads both fields, but the service parser never maps them to run arguments, and neither is in its list of known fields. docs/compose.md lists cgroup_parent as unimplemented.

Fix

Map them in the service parser:

  • services.<SERVICE>.cgroup_parent -> --cgroup-parent
  • services.<SERVICE>.cgroup -> --cgroupns

Both are added to the known-field list, so the warning goes away. cgroup_parent is removed from the unimplemented list in docs/compose.md.

Verification

Built from this branch and from its merge base with main, and run with nerdctl compose up using the systemd cgroup driver on cgroup v2, containerd 2.2.1 and runc 1.3.3. The cgroup was read from /proc/<pid>/cgroup, and the namespace was compared against the host's /proc/self/ns/cgroup.

service field unpatched patched
none /system.slice/nerdctl-<id>.scope, private ns same
cgroup_parent: rcs-thirdparty.slice /system.slice/nerdctl-<id>.scope, Ignoring: [CgroupParent] /rcs.slice/rcs-thirdparty.slice/nerdctl-<id>.scope
cgroup: host private ns, Ignoring: [Cgroup] host ns
cgroup: private private ns, Ignoring: [Cgroup] private ns

Test

TestParseCgroup asserts that both fields become --cgroupns=host and --cgroup-parent=foo.slice.

@addemod
addemod marked this pull request as ready for review September 25, 2026 13:58
@addemod

addemod commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

This invalidates PR #5227

@AkihiroSuda

Copy link
Copy Markdown
Member

Please squash the commits

Pass cgroup_parent and cgroup through to nerdctl run as --cgroup-parent and --cgroupns, which compose previously ignored.

Signed-off-by: Adam Clettborn <a.clettborn@gmail.com>
@addemod
addemod force-pushed the fix/compose-cgroup-parent branch from e70b09c to 702389a Compare September 30, 2026 19:36
@addemod

addemod commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Please squash the commits

@AkihiroSuda Done!

@AkihiroSuda AkihiroSuda added this to the v2.4.1 milestone Oct 2, 2026

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda
AkihiroSuda merged commit a5d2c03 into containerd:main Oct 2, 2026
62 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants