Add --sysctl and --privileged flags to run/create - #2064
Open
ronandi wants to merge 2 commits into
Open
Conversation
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.
3 tasks
Contributor
|
@ronandi Have you tried this sort of thing for sysctl: |
Author
|
Thank you for that @jglogan! I'm trying to run a kube cluster and 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2041.
Problem
container 1.2.0 picked up containerization's secure-by-default changes (default
readonlyPathsincludes/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,maskedPathsonContainerConfiguration) already existed — this exposes it.Verification (against 1.2.0 services)
--sysctl net.ipv4.ip_forward=1: value lands in the guest (cat= 1)--privilegedubuntu:sysctl -wsucceeds,mount -o remount,ro /syssucceeds--privilegedkindest/node:v1.36.1: boots cleanly (containerd active, kubelet starts) — fails hard without the flagParser.sysctlsunit tests (note:swift testneeds 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.