Skip to content

Conversation

@yashkukrecha
Copy link

This PR makes nerdctl default the container's net.ipv4.ip_unprivileged_port_start sysctl to 0, unless the user has explicitly set this sysctl via --sysctl.

Key changes:

  • Adds a new helper withDefaultUnprivilegedPortSysctl in pkg/cmd/container/container.go.
  • Applies this helper during container creation, after user-supplied sysctls are parsed.
  • If the user passes a --sysctl for net.ipv4.ip_unprivileged_port_start, nerdctl does not override it.

Note: Host-wide sysctl configuration and containerd-rootless-setuptool.sh were intentionally left unchanged in this PR to keep the scope focused on the container namespace default requested in the issue.

Fixes #4595

opts = append(opts, umaskOpts...)

if !isHostNetwork(netLabelOpts) {
opts = append(opts, withDefaultUnprivilegedPortSysctl(options.Sysctl))
Copy link
Member

Choose a reason for hiding this comment

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

conflicts with:

opts = append(opts, WithSysctls(strutil.ConvertKVStringsToMap(options.Sysctl)))

Copy link
Author

Choose a reason for hiding this comment

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

I added the defaulting for net.ipv4.ip_unprivileged_port_start in create.go, building on top of the behavior in run_linux.go. Does this still conflict?

@AkihiroSuda
Copy link
Member

Please fix the lint errors, squash the commits, and sign off the DCO

…iners Signed-off-by: Yash Kukrecha <ykukrecha@gmail.com>
@yashkukrecha yashkukrecha force-pushed the fix-unprivileged-port-default branch from 9d214b1 to 56f05ed Compare November 27, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants