Skip to content

fix(apple): grant all capabilities to engine container - #13460

Merged
eunomie merged 1 commit into
dagger:mainfrom
eunomie:fix-apple-containers-support
Jun 16, 2026
Merged

eunomie merged 1 commit into
dagger:mainfrom
eunomie:fix-apple-containers-support

Conversation

@eunomie

@eunomie eunomie commented Jun 16, 2026

Copy link
Copy Markdown
Member

Problem

Running the Dagger engine through Apple's container CLI 1.0.0 crashes the engine immediately on startup:

dagger-engine: install resolv.conf: remount /etc/resolv.conf to upstream alias: operation not permitted

This worked on older container releases (e.g. 0.4.1-49) and broke after upgrading to 1.0.0.

Fixes #13459

Root cause

container 1.0.0 reduced the default capability set and introduced --cap-add/--cap-drop. From the 1.0.0 release notes:

Support --cap-add and --cap-drop for containers. The default set of capabilities has been reduced, so if you need the old behavior that grants all capabilities, you will need to delete and recreate your containers.

CAP_SYS_ADMIN is no longer granted by default. The engine needs it to bind-mount /etc/resolv.conf during network setup (netinst.InstallResolvconf), one of the very first things it does at startup — hence the immediate operation not permitted (EPERM) crash.

The shared provisioning code already sets runOpts.privileged = true (the Docker driver maps this to --privileged), but the apple driver ignored it and passed no capability flags. With older container versions this was harmless because all capabilities were granted by default.

Fix

Apple's container has no --privileged flag; --cap-add ALL is the documented equivalent (--cap-drop ALL --cap-add ALL grants everything). Honor opts.privileged in the apple driver by passing --cap-add ALL.

Extracted the argument construction into a runArgs helper so it can be unit-tested.

Testing

  • Added unit tests asserting --cap-add ALL is present when privileged and absent otherwise.
  • go build / go vet / go test ./engine/client/drivers/ pass.
  • Needs a manual confirmation on an Apple Silicon Mac with container 1.0.0 (reporter can reproduce).

Apple's `container` 1.0.0 reduced the default capability set and now
requires `--cap-add`/`--cap-drop` to customize it. CAP_SYS_ADMIN is no
longer granted by default.

The engine needs CAP_SYS_ADMIN to bind-mount /etc/resolv.conf during
network setup (netinst.InstallResolvconf), which is one of the first
things it does at startup. Without it, the engine crashes immediately
with:

    install resolv.conf: remount /etc/resolv.conf to upstream alias: operation not permitted

The shared provisioning code already sets runOpts.privileged = true (the
Docker driver maps this to --privileged), but the apple driver ignored
it. Apple's `container` has no --privileged flag; --cap-add ALL is the
documented equivalent. Honor opts.privileged by passing it.

Fixes dagger#13459

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie force-pushed the fix-apple-containers-support branch from 82349bb to 3740886 Compare June 16, 2026 05:51
@eunomie

eunomie commented Jun 16, 2026

Copy link
Copy Markdown
Member Author
$ _EXPERIMENTAL_DAGGER_RUNNER_HOST=image+apple://registry.dagger.io/engine:latest ./bin/dagger -M -c 'container | from alpine | with-exec echo,hello,world | stdout'
✔ connect 0.3s
✔ loading type definitions 0.2s

$ container: Container! 0.0s CACHED
✔ .from(address: "alpine"): Container! 0.7s
$ withExec echo hello world 0.0s CACHED
✔ .stdout: String! 0.0s

hello world

@eunomie
eunomie merged commit 8d475cc into dagger:main Jun 16, 2026
79 checks passed
@eunomie
eunomie deleted the fix-apple-containers-support branch June 16, 2026 14:57
@marcosnils marcosnils modified the milestones: v0.21.6, v0.21.7 Jun 16, 2026
marcosnils pushed a commit that referenced this pull request Jun 16, 2026
Apple's `container` 1.0.0 reduced the default capability set and now
requires `--cap-add`/`--cap-drop` to customize it. CAP_SYS_ADMIN is no
longer granted by default.

The engine needs CAP_SYS_ADMIN to bind-mount /etc/resolv.conf during
network setup (netinst.InstallResolvconf), which is one of the first
things it does at startup. Without it, the engine crashes immediately
with:

    install resolv.conf: remount /etc/resolv.conf to upstream alias: operation not permitted

The shared provisioning code already sets runOpts.privileged = true (the
Docker driver maps this to --privileged), but the apple driver ignored
it. Apple's `container` has no --privileged flag; --cap-add ALL is the
documented equivalent. Honor opts.privileged by passing it.

Fixes #13459

Signed-off-by: Yves Brissaud <[email protected]>
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
dagger 0.21.7

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## v0.21.7 - 2026-06-17

### Changed

- Bump default CNI IP address pool size to reduce address exhaustion under high container concurrency. by @sipsma in dagger/dagger#13394
- Bump Dang to v2.1.1, moving JSON encoding behind the `JSON` namespace (with a deprecated top-level `toJSON`) and picking up constructor scope and nullable input fixes. by @vito in dagger/dagger#13482

### Fixed

- `.env` file handling so non-matching variables are kept as hidden expansion context instead of being dropped, allowing later variables to expand against them. by @marcosnils in dagger/dagger#13490
- Filesync so syncing a re-included file under a gitignored directory (e.g. `foo/` ignored with `!foo/bar.txt`) no longer fails with `no such file or directory`; ignored parent dirs are now created on demand for visible descendants. by @grouville in dagger/dagger#13439
- A concurrent map panic during GC by guarding session client map iteration, preventing fatal `concurrent map iteration and map write` crashes. by @sipsma in dagger/dagger#13474
- Go SDK codegen so SDK auth config is forwarded to typedef generation, allowing modules with private transitive Go dependencies to resolve during codegen. by @grouville in dagger/dagger#13457
- Core enum handling to preserve conventional enum member names. by @shykes in dagger/dagger#13435
- The Apple `container` driver to honor the privileged option by granting all capabilities (`--cap-add ALL`), so the engine can bind-mount `/etc/resolv.conf` on startup with `container` 1.0.0's reduced default capability set. by @eunomie in dagger/dagger#13460
- Dang directive argument resolution so `@cache` (and other directive) arguments resolve against the declaring type's file scope, fixing `FunctionCachePolicy not found in env` errors in multi-file modules. by @vito in dagger/dagger#13455
- The report-mode heartbeat so it waits for its goroutine to exit before final render, avoiding interleaved output. by @kpenfound in dagger/dagger#13425
- Nullable result unwrapping for SDK input so nullable values are passed correctly into SDK functions. by @shykes in dagger/dagger#13401

### What to do next?

- Read the [documentation](https://docs.dagger.io)
- Join our [Discord server](https://discord.gg/dagger-io)
- Follow us on [Twitter](https://twitter.com/dagger_io)

</pre>
  <p>View the full release notes at <a href="https://github.com/dagger/dagger/releases/tag/v0.21.7">https://github.com/dagger/dagger/releases/tag/v0.21.7</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!11763
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.

🐞 Dagger engine crashes on startup with Apple container 1.0.0 (reduced default capabilities)

3 participants