Skip to content

Add --sysctl and --privileged flags to run/create - #2064

Open
ronandi wants to merge 2 commits into
apple:mainfrom
ronandi:feat/sysctl-privileged-flags
Open

Add --sysctl and --privileged flags to run/create#2064
ronandi wants to merge 2 commits into
apple:mainfrom
ronandi:feat/sysctl-privileged-flags

Conversation

@ronandi

@ronandi ronandi commented Aug 3, 2026

Copy link
Copy Markdown

Fixes #2041.

Problem

container 1.2.0 picked up containerization's secure-by-default changes (default readonlyPaths includes /proc/sys, restricted capability set) with no CLI opt-out. Guests can no longer write sysctls or remount mounts, so Kubernetes node images (kindest/node, rancher/k3s) and docker-in-docker engines like dagger fail to boot.

Change

Two Docker-compatible flags on run/create:

  • --sysctl key=value (repeatable): sets guest sysctls at creation. vminitd applies them before the read-only remount, so they compose with the default readonly paths.
  • --privileged: grants the full capability set and clears the default masked/readonly paths. Every container is its own VM with its own kernel, so an explicit opt-in escape hatch is proportionate and matches Docker's UX.

The API plumbing (sysctls, readonlyPaths, maskedPaths on ContainerConfiguration) already existed — this exposes it.

Verification (against 1.2.0 services)

  • --sysctl net.ipv4.ip_forward=1: value lands in the guest (cat = 1)
  • --privileged ubuntu: sysctl -w succeeds, mount -o remount,ro /sys succeeds
  • --privileged kindest/node:v1.36.1: boots cleanly (containerd active, kubelet starts) — fails hard without the flag
  • Added Parser.sysctls unit tests (note: swift test needs full Xcode; I only had CLT locally, so tests are unrun locally — CI should cover)

Defaults are unchanged: without the flags, behavior is exactly 1.2.0.

container 1.2.0 picked up containerization's secure-by-default changes
(default readonlyPaths include /proc/sys, restricted capability set),
which removed the ability to write sysctls or remount mounts in the
guest with no way to opt out from the CLI. Kubernetes node images
(kindest/node, rancher/k3s) and docker-in-docker engines like dagger
fail to boot as a result (fixes apple#2041).

Add two Docker-compatible flags to run/create:

- --sysctl key=value (repeatable) sets guest sysctls at creation; the
  guest applies them before the read-only remount, so they compose with
  the default readonly paths.
- --privileged grants the full capability set and clears the default
  masked/readonly paths. Since every container is its own VM with its
  own kernel, an explicit opt-in escape hatch is proportionate and
  matches user expectations from Docker.
@jglogan

jglogan commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@ronandi Have you tried this sort of thing for sysctl:

--kernel-arg sysctl.net.ipv4.ip_forward=1

@ronandi

ronandi commented Aug 4, 2026

Copy link
Copy Markdown
Author

Thank you for that @jglogan! --kernel-arg sysctl.net.ipv4.ip_forward=1 does work on 1.2.0 (verified: guest reads 1). That covers the sysctl half

I'm trying to run a kube cluster and kindest/node's entrypoint dies at mount -o remount,ro /sys with EPERM, and kernel args can't help there. With --privileged it boots cleanly (containerd + kubelet come up).

Use case, for context: running a long-lived local Kubernetes cluster on apple/container (kubeadm/k3s node images). Kubernetes nodes fundamentally need to write sysctls and remount /sys at boot, so 1.2.0's defaults make node images unbootable

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.

[Bug]: /proc/sys/net/ipv4/ip_forward is no longer writable (regression)

2 participants