Skip to content

feat(router): give the router its own ddev-router-traefik volume, for #8895, fixes #8975 - #8945

Merged
rfay merged 4 commits into
ddev:mainfrom
rfay:20261014_rfay_router_volume
Oct 28, 2026
Merged

rfay merged 4 commits into
ddev:mainfrom
rfay:20261014_rfay_router_volume

Conversation

@rfay

@rfay rfay commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

The router now keeps its Traefik config, certs and acme.json in its own ddev-router-traefik volume, mounted at the same /mnt/ddev-global-cache/traefik path, instead of mounting the shared ddev-global-cache volume. Nothing else can then change acme.json's mode, and the router entrypoint resets it to 600 on every start.

The Issue

ddev-global-cache is mounted read-write by web, db and the router, which providers like Apple container may not allow. The router only uses traefik/. Traefik also ignores acme.json when its mode isn't 600, and anything with write access to the shared volume could widen it, as in #8849, which silently disables Let's Encrypt.

How This PR Solves The Issue

On the first router start, DDEV creates ddev-router-traefik and copies ddev-global-cache/traefik into it, so existing Let's Encrypt certificates in acme.json carry over with mode 600. Everything else in the volume is pushed from the host on each start. The old traefik/ directory is left in ddev-global-cache, so a downgrade still works.

Cleanup on ddev stop and ddev delete mounts the new volume only if it exists, so a cleanup can't create it empty before the copy has run.

Manual Testing Instructions

ddev utility download-ddev --pr 8945
export PATH="$HOME/tmp/ddev-download-ddev/pr-8945:$PATH"
ddev poweroff
docker run --rm -v ddev-global-cache:/m busybox sh -c 'mkdir -p /m/traefik && touch /m/traefik/acme.json && chmod 622 /m/traefik/acme.json'
mkdir -p ~/tmp/routervol && cd ~/tmp/routervol
ddev config --project-type=php --omit-containers=db && ddev start
# Expect acme.json copied with mode 600, and the router mounting only ddev-router-traefik
docker run --rm -v ddev-router-traefik:/t busybox ls -la /t
docker inspect ddev-router --format '{{range .Mounts}}{{.Name}}:{{.Destination}} {{end}}'
docker run --rm -v ddev-router-traefik:/t busybox chmod 644 /t/acme.json
ddev poweroff && ddev start
# Expect 600 again
docker exec ddev-router stat -c '%a' /mnt/ddev-global-cache/traefik/acme.json
ddev stop
# Expect routervol_merged.yaml gone
docker run --rm -v ddev-router-traefik:/t busybox ls /t/config

Automated Testing Overview

TestTraefikSimple plants a mode-644 acme.json in ddev-router-traefik, then checks that ddev-router mounts only that volume and that acme.json is 600 after start. The other router and Traefik tests in pkg/ddevapp also exercise the new volume, since the router no longer starts without it.

Release/Deployment Notes

The router image changes. To clear router state, remove the ddev-router-traefik volume; removing ddev-global-cache no longer affects the router.

🤖 Developed with assistance from Claude Code

Co-Authored-By: Claude Opus 5.5 [email protected]

@rfay
rfay requested review from a team as code owners October 14, 2026 17:15
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file enhancement labels Oct 14, 2026
@github-actions

Copy link
Copy Markdown

Pushed updated container image(s) for this PR:

  • ddev/ddev-traefik-router:2cd661f210

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Download this PR's build for your OS and architecture with:

ddev utility download-ddev --pr 8945

Or download the artifact for your OS and architecture directly:

See Testing a PR.

Open in GitHub Codespaces

@rfay
rfay requested a review from stasadev October 18, 2026 16:24
@stasadev stasadev changed the title feat(router): give the router its own ddev-router-traefik volume, for #8895 feat(router): give the router its own ddev-router-traefik volume, for #8895, fixes #8975 Oct 19, 2026
@rfay

rfay commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

Weird. The volume should be named ddev-traefik-router shouldn't it?

@rfay

rfay commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

I guess the naming here was based on parallel usage to the other now-obsolete volume, ddev-router-letsencrypt, removed in #8977

The container name is ddev-router; the logic behind the naming was "traefik stuff for ddev-router, thus ddev-router-traefik". We could rename the volume to ddev-router and have a traefik subdir in it, and then do some fancy things to mount it at the same place or symlink it, etc. I'm not sure it's worth fiddling with.

@rfay
rfay force-pushed the 20261014_rfay_router_volume branch 2 times, most recently from 006339d to 31a4a2b Compare October 21, 2026 02:57
@github-actions

Copy link
Copy Markdown

Pushed updated container image(s) for this PR:

  • ddev/ddev-traefik-router:936cf537be

@rfay
rfay force-pushed the 20261014_rfay_router_volume branch from 31a4a2b to d0447e8 Compare October 22, 2026 15:01

@stasadev stasadev 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.

Claude Code ran an upgrade from main to this PR on rootful Docker with the old router still running. The router came back with only ddev-router-traefik mounted, and a planted acme.json was copied with its content, mode 622 changed to 600. ddev stop, ddev delete and a downgrade back to main also worked.

The name ddev-router-traefik is fine with me, I wouldn't rename it.

  1. These still say files are copied into ddev-global-cache, and the README files are #ddev-generated, so users get them:
    • pkg/ddevapp/global_dotddev_assets/traefik/certs/README.txt
    • pkg/ddevapp/global_dotddev_assets/traefik/config/README.txt
    • the comment in pkg/ddevapp/ddevapp.go above configureTraefikForApp(app)
  2. The PR body says the router's bats tests cover the new volume, but they mount the test volume at /mnt/ddev-global-cache, so they never use the new mount. Maybe add a small check to TestTraefikSimple that the router mounts only ddev-router-traefik and that acme.json is 600?

Small things:

  1. ddev-router-traefik in sharedVolumeNames is never used. That map is checked against the project's compose volumes, and the router volume is not in them.

🤖 Reviewed with assistance from Claude Code

rfay and others added 2 commits October 27, 2026 10:47
…dev#8895

The router now keeps its Traefik config, certs and `acme.json` in its own `ddev-router-traefik` volume, mounted at the same `/mnt/ddev-global-cache/traefik` path, instead of mounting the shared `ddev-global-cache` volume. Nothing else can then change `acme.json`'s mode, and the router entrypoint resets it to 600 on every start.

- For ddev#8895

`ddev-global-cache` is mounted read-write by web, db and the router, which providers like Apple container may not allow. The router only uses `traefik/`. Traefik also ignores `acme.json` when its mode isn't 600, and anything with write access to the shared volume could widen it, as in ddev#8849, which silently disables Let's Encrypt.

On the first router start, DDEV creates `ddev-router-traefik` and copies `ddev-global-cache/traefik` into it, so existing Let's Encrypt certificates in `acme.json` carry over with mode 600. Everything else in the volume is pushed from the host on each start. The old `traefik/` directory is left in `ddev-global-cache`, so a downgrade still works.

Cleanup on `ddev stop` and `ddev delete` mounts the new volume only if it exists, so a cleanup can't create it empty before the copy has run.

```bash
ddev utility download-ddev --pr 8945
export PATH="$HOME/tmp/ddev-download-ddev/pr-8945:$PATH"
ddev poweroff
docker run --rm -v ddev-global-cache:/m busybox sh -c 'mkdir -p /m/traefik && touch /m/traefik/acme.json && chmod 622 /m/traefik/acme.json'
mkdir -p ~/tmp/routervol && cd ~/tmp/routervol
ddev config --project-type=php --omit-containers=db && ddev start
docker run --rm -v ddev-router-traefik:/t busybox ls -la /t
docker inspect ddev-router --format '{{range .Mounts}}{{.Name}}:{{.Destination}} {{end}}'
docker run --rm -v ddev-router-traefik:/t busybox chmod 644 /t/acme.json
ddev poweroff && ddev start
docker exec ddev-router stat -c '%a' /mnt/ddev-global-cache/traefik/acme.json
ddev stop
docker run --rm -v ddev-router-traefik:/t busybox ls /t/config
```

Existing router and Traefik tests in `pkg/ddevapp` and the router image's bats tests cover the new volume, since the router no longer starts without it.

The router image changes. To clear router state, remove the `ddev-router-traefik` volume; removing `ddev-global-cache` no longer affects the router.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rfay
rfay force-pushed the 20261014_rfay_router_volume branch from d0447e8 to b762a0f Compare October 27, 2026 16:48
@github-actions

Copy link
Copy Markdown

Pushed updated container image(s) for this PR:

  • ddev/ddev-traefik-router:ef72c327c5

@stasadev

Copy link
Copy Markdown
Member

@rfay a reminder about the review above, since the rebase didn't change these:

  1. traefik/certs/README.txt, traefik/config/README.txt, and the comment above configureTraefikForApp(app) in ddevapp.go still say files are copied into ddev-global-cache.
  2. No test checks the new mount. The PR body still says the bats tests cover it, but they mount the test volume at /mnt/ddev-global-cache.
  3. ddev-router-traefik in sharedVolumeNames is still unused.

🤖 Developed with assistance from Claude Code

…ces, for ddev#8895

- `TestTraefikSimple` plants a mode-644 `acme.json` in `ddev-router-traefik`, then checks that `ddev-router` mounts only that volume and that `acme.json` is 600 after start.
- The `traefik/certs` and `traefik/config` READMEs and the comment above `configureTraefikForApp()` name the router volume instead of `ddev-global-cache`.
- Remove `ddev-router-traefik` from `sharedVolumeNames`; that map is checked against a project's compose volumes, which never include it.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rfay

rfay commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Thanks, fixed. I guess I did those and lost track and didn't get pushed

@stasadev
stasadev self-requested a review October 28, 2026 15:57

@stasadev stasadev 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, all three points are fixed.

Claude Code ran TestTraefikSimple on rootful Docker. It passes on this PR, and fails with the router image from main (ce1c55b924), which doesn't have the new chmod:

expected: "600"
actual  : "644"
Messages: acme.json should be mode 600 in the router

One small thing: the cleanup in TestCustomCerts (pkg/ddevapp/ddevapp_test.go) still removes /mnt/ddev-global-cache/traefik/certs/<name>.* from the web container. That's now the old copy in ddev-global-cache, not the router's. It does no harm, because app.Stop(true, false) right after it removes the router certs, so that part can be dropped.

🤖 Reviewed with assistance from Claude Code

…dev#8895

The router's certs are now in `ddev-router-traefik`, so the `ddev-global-cache/traefik/certs` files the cleanup removed were the old copy. `app.Stop(true, false)` removes the router's certs.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@stasadev stasadev 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.

Looks good to me.

@rfay
rfay merged commit 8ca2a5f into ddev:main Oct 28, 2026
50 of 54 checks passed
@rfay
rfay deleted the 20261014_rfay_router_volume branch October 28, 2026 20:06
rfay added a commit to rfay/ddev that referenced this pull request Oct 31, 2026
… around two socktainer bugs, for ddev#7372 [skip ci]

The rebase onto e907890 left app_compose_template.yaml with an
unbalanced `if .BindGlobalCache` and web/db without GlobalCacheMount,
and kept router/Traefik bind-mount code that upstream's
ddev-router-traefik volume (ddev#8945) made obsolete.

- Bind-mount only ddev-global-cache (now just mkcert/) on apple
  container; the router, project cache and global commands use
  upstream's volumes and copies unchanged.
- Drop NotifyRouterOfTraefikConfigChange, mergeCopyDir and the
  host-side list/remove helpers.
- start-chown skips the volumes of running containers, and Stop()
  cleans router files through the running router, since apple
  container refuses a second writer on a volume.
- CopyIntoContainer extracts with tar inside the container on apple
  container: its copy-in drops files under a volume mount.
- FindImagesByLabels re-checks labels: socktainer ignores the label
  filter (socktainer#491), so `ddev delete` removed every image.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Nov 23, 2026
…#7372

## Short Summary (TL;DR)

DDEV detects Apple Container behind [socktainer](https://github.com/socktainer/socktainer) and adapts to it, so projects start and run there. Support is marked experimental, and nothing changes on other providers.

## The Issue

- Fixes ddev#7372

Apple Container runs each container in its own VM. A named volume takes either one read-write attachment or any number of read-only ones. A Unix socket in one container can't be reached from another. Ports below 1024 can't be published. socktainer, the Docker-compatible API in front of it, still has gaps. Most of the volume sharing DDEV used to depend on was removed upstream for ddev#8895 (ddev#8945, ddev#9024, ddev#8956, ddev#8944, ddev#9041, ddev#9042, ddev#9045). ddev#9040, ddev#9046, ddev#9061, ddev#9108, ddev#9115 and ddev#9121 also came out of this work. What's left is here.

## How This PR Solves The Issue

DDEV detects the provider through socktainer's `docker version` output (`IsAppleContainer()`). Every change below applies only on that provider.

- `ddev version`, `ddev utility dockercheck`, `ddev utility port-diagnose` and instrumentation report the provider as `apple-container`.
- `ddev start` and `ddev utility dockercheck` warn when socktainer is older than 1.6.1. Builds from source report no release version, so DDEV doesn't compare them.
- `ddev-ssh-agent` is always omitted, because web can't attach a volume another VM holds. With `ssh_agent_upstream` set, web bind-mounts that host socket directly, and Apple Container relays it into the VM. `host` uses `SSH_AUTH_SOCK`. `ddev auth ssh` explains this instead of adding keys to an agent web can't reach.
- `CopyIntoContainer` extracts with `tar` inside the container. socktainer 1.6.1 ignores a gzipped archive ([socktainer#484](socktainer/socktainer#484)) and drops each file's owner and mtime ([socktainer#514](socktainer/socktainer#514)). Both are fixed on socktainer `main` but not released.
- The mkcert CA archive leaves out its directory entry, which a never-started container refuses ([socktainer#502](socktainer/socktainer#502)).
- Project images build one service at a time. Concurrent image loads can leave a tag on its old image ([socktainer#518](socktainer/socktainer#518)), and Compose's bake build loads them all at once. Compose's concurrency limit doesn't reach the bake path, so DDEV calls `Build` once per service.
- Image pulls and `BuildPlatformToPull` use `linux/<arch>`, because socktainer's `/version` reports `Os: macOS` ([socktainer#517](socktainer/socktainer#517)).
- `host.docker.internal` is `host-gateway`, which socktainer resolves to the network gateway where the Mac answers.
- `FindContainersByVolume` matches `Mounts` itself, because socktainer ignores the `volume=` filter.
- Add-on installs get the same virtiofs propagation delay as Lima and Colima.
- Docs: an experimental Apple Container tab on the macOS Docker installation page, with setup, the Local Network prompt, SSH keys, limitations and a fix for a hanging `container system start`.

Mutagen works and is the default, as on any macOS provider.

Known limitations, each documented or named by a test skip:

- **Ports below 1024** can't be published. The router needs `ddev config global --router-http-port=8080 --router-https-port=8443`. The global setting matters: with 80/443 there, the router fails to bind even when the project sets 8080/8443.
- **Single-writer volumes:** add-on services that share a named volume with a running container fail to start. Apple closed [apple/container#1133](apple/container#1133) as working as designed.
- **Open socktainer issues:** [ddev#518](socktainer/socktainer#518), [ddev#519](socktainer/socktainer#519), [ddev#520](socktainer/socktainer#520), [ddev#517](socktainer/socktainer#517), [ddev#514](socktainer/socktainer#514), [ddev#510](socktainer/socktainer#510), [ddev#504](socktainer/socktainer#504), [ddev#499](socktainer/socktainer#499), [ddev#498](socktainer/socktainer#498), [ddev#497](socktainer/socktainer#497).
- **Unreleased socktainer fixes:** `main` has fixes for ddev#505, ddev#514, ddev#484 and ddev#498, the last still in PR [ddev#528](socktainer/socktainer#528). After the next release, a follow-up can raise `SocktainerMinVersion` and remove the matching skips and the `tar` workaround.
- socktainer 1.6.1 warns that it was built for Apple Container 1.6.1 when run with 1.7.1. The CI testbots run that pair, and it passes.

## Manual Testing Instructions

This needs macOS 26 on Apple silicon. The setup is in the new docs tab: https://ddev--8656.org.readthedocs.build/en/8656/users/install/docker-installation/

```bash
brew install socktainer docker docker-buildx
container system start
socktainer &
docker context use socktainer
ddev utility download-ddev --pr 8656
export PATH="$HOME/tmp/ddev-download-ddev/pr-8656:$PATH"
ddev config global --router-http-port=8080 --router-https-port=8443 --ssh-agent-upstream=host
mkdir -p ~/tmp/appletest && cd ~/tmp/appletest
echo '<?php echo gethostname();' > index.php
ddev config --project-type=php --docroot=.
ddev start -y
# Expect: macOS asks to allow container-runtime-linux on the local network the first time; click Allow
curl -s http://appletest.ddev.site:8080/
# Expect: appletest-web
ddev mutagen st -l | grep Status
# Expect: Status: Watching for changes
ddev exec ssh-add -l
# Expect: the keys that `ssh-add -l` lists on the host
ddev auth ssh
# Expect: an explanation that web uses the host's agent directly
ddev utility dockercheck
# Expect: socktainer version: 1.6.1
```

On another provider, run `ddev debug compose-config` in a project. Confirm that web still mounts `ddev-ssh-agent_socket_dir` and that `host.docker.internal` is unchanged.

## Automated Testing Overview

The Buildkite pipeline [macos-socktainer](https://buildkite.com/ddev/macos-socktainer) runs the suite with `DOCKER_TYPE=socktainer` and router ports 8080/8443. It runs on testbots with Apple Container 1.7.1 and socktainer 1.6.1. Build 40 passed on this branch before it was squashed.

- `TestAppleContainerSSHAgent` covers the host-agent mount. The `ddev-ssh-agent` tests skip there.
- Tests that hit a known socktainer or Apple Container gap skip on `IsAppleContainer()`, and each skip names its cause.
- `SkipUnlessDefaultEnvironment` still skips its tests there through its Mutagen check.

## Release/Deployment Notes

Apple Container support is experimental. The `macos-socktainer` pipeline builds only this branch, so its branch filter needs widening after merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Nov 24, 2026
…#7372

## Short Summary (TL;DR)

DDEV detects Apple Container behind [socktainer](https://github.com/socktainer/socktainer) and adapts to it, so projects start and run there. Support is marked experimental, and nothing changes on other providers.

## The Issue

- Fixes ddev#7372

Apple Container runs each container in its own VM. A named volume takes either one read-write attachment or any number of read-only ones. A Unix socket in one container can't be reached from another. Ports below 1024 can't be published. socktainer, the Docker-compatible API in front of it, still has gaps. Most of the volume sharing DDEV used to depend on was removed upstream for ddev#8895 (ddev#8945, ddev#9024, ddev#8956, ddev#8944, ddev#9041, ddev#9042, ddev#9045). ddev#9040, ddev#9046, ddev#9061, ddev#9108, ddev#9115 and ddev#9121 also came out of this work. What's left is here.

## How This PR Solves The Issue

DDEV detects the provider through socktainer's `docker version` output (`IsAppleContainer()`). Every change below applies only on that provider.

- `ddev version`, `ddev utility dockercheck`, `ddev utility port-diagnose` and instrumentation report the provider as `apple-container`.
- `ddev start` and `ddev utility dockercheck` warn when socktainer is older than 1.6.1. Builds from source report no release version, so DDEV doesn't compare them.
- `ddev-ssh-agent` is always omitted, because web can't attach a volume another VM holds. With `ssh_agent_upstream` set, web bind-mounts that host socket directly, and Apple Container relays it into the VM. `host` uses `SSH_AUTH_SOCK`. `ddev auth ssh` explains this instead of adding keys to an agent web can't reach.
- `CopyIntoContainer` extracts with `tar` inside the container. socktainer 1.6.1 ignores a gzipped archive ([socktainer#484](socktainer/socktainer#484)) and drops each file's owner and mtime ([socktainer#514](socktainer/socktainer#514)). Both are fixed on socktainer `main` but not released.
- The mkcert CA archive leaves out its directory entry, which a never-started container refuses ([socktainer#502](socktainer/socktainer#502)).
- Project images build one service at a time. Concurrent image loads can leave a tag on its old image ([socktainer#518](socktainer/socktainer#518)), and Compose's bake build loads them all at once. Compose's concurrency limit doesn't reach the bake path, so DDEV calls `Build` once per service.
- Image pulls and `BuildPlatformToPull` use `linux/<arch>`, because socktainer's `/version` reports `Os: macOS` ([socktainer#517](socktainer/socktainer#517)).
- `host.docker.internal` is `host-gateway`, which socktainer resolves to the network gateway where the Mac answers.
- `FindContainersByVolume` matches `Mounts` itself, because socktainer ignores the `volume=` filter.
- Add-on installs get the same virtiofs propagation delay as Lima and Colima.
- Docs: an experimental Apple Container tab on the macOS Docker installation page, with setup, the Local Network prompt, SSH keys, limitations and a fix for a hanging `container system start`.

Mutagen works and is the default, as on any macOS provider.

Known limitations, each documented or named by a test skip:

- **Ports below 1024** can't be published. The router needs `ddev config global --router-http-port=8080 --router-https-port=8443`. The global setting matters: with 80/443 there, the router fails to bind even when the project sets 8080/8443.
- **Single-writer volumes:** add-on services that share a named volume with a running container fail to start. Apple closed [apple/container#1133](apple/container#1133) as working as designed.
- **Open socktainer issues:** [ddev#518](socktainer/socktainer#518), [ddev#519](socktainer/socktainer#519), [ddev#520](socktainer/socktainer#520), [ddev#517](socktainer/socktainer#517), [ddev#514](socktainer/socktainer#514), [ddev#510](socktainer/socktainer#510), [ddev#504](socktainer/socktainer#504), [ddev#499](socktainer/socktainer#499), [ddev#498](socktainer/socktainer#498), [ddev#497](socktainer/socktainer#497).
- **Unreleased socktainer fixes:** `main` has fixes for ddev#505, ddev#514, ddev#484 and ddev#498, the last still in PR [ddev#528](socktainer/socktainer#528). After the next release, a follow-up can raise `SocktainerMinVersion` and remove the matching skips and the `tar` workaround.
- socktainer 1.6.1 warns that it was built for Apple Container 1.6.1 when run with 1.7.1. The CI testbots run that pair, and it passes.

## Manual Testing Instructions

This needs macOS 26 on Apple silicon. The setup is in the new docs tab: https://ddev--8656.org.readthedocs.build/en/8656/users/install/docker-installation/

```bash
brew install socktainer docker docker-buildx
container system start
socktainer &
docker context use socktainer
ddev utility download-ddev --pr 8656
export PATH="$HOME/tmp/ddev-download-ddev/pr-8656:$PATH"
ddev config global --router-http-port=8080 --router-https-port=8443 --ssh-agent-upstream=host
mkdir -p ~/tmp/appletest && cd ~/tmp/appletest
echo '<?php echo gethostname();' > index.php
ddev config --project-type=php --docroot=.
ddev start -y
# Expect: macOS asks to allow container-runtime-linux on the local network the first time; click Allow
curl -s http://appletest.ddev.site:8080/
# Expect: appletest-web
ddev mutagen st -l | grep Status
# Expect: Status: Watching for changes
ddev exec ssh-add -l
# Expect: the keys that `ssh-add -l` lists on the host
ddev auth ssh
# Expect: an explanation that web uses the host's agent directly
ddev utility dockercheck
# Expect: socktainer version: 1.6.1
```

On another provider, run `ddev debug compose-config` in a project. Confirm that web still mounts `ddev-ssh-agent_socket_dir` and that `host.docker.internal` is unchanged.

## Automated Testing Overview

The Buildkite pipeline [macos-socktainer](https://buildkite.com/ddev/macos-socktainer) runs the suite with `DOCKER_TYPE=socktainer` and router ports 8080/8443. It runs on testbots with Apple Container 1.7.1 and socktainer 1.6.1. Build 40 passed on this branch before it was squashed.

- `TestAppleContainerSSHAgent` covers the host-agent mount. The `ddev-ssh-agent` tests skip there.
- Tests that hit a known socktainer or Apple Container gap skip on `IsAppleContainer()`, and each skip names its cause.
- `SkipUnlessDefaultEnvironment` still skips its tests there through its Mutagen check.

## Release/Deployment Notes

Apple Container support is experimental. The `macos-socktainer` pipeline builds only this branch, so its branch filter needs widening after merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Nov 25, 2026
…#7372

## Short Summary (TL;DR)

DDEV detects Apple Container behind [socktainer](https://github.com/socktainer/socktainer) and adapts to it, so projects start and run there. Support is marked experimental, and nothing changes on other providers.

## The Issue

- Fixes ddev#7372

Apple Container runs each container in its own VM. A named volume takes either one read-write attachment or any number of read-only ones. A Unix socket in one container can't be reached from another. Ports below 1024 can't be published. socktainer, the Docker-compatible API in front of it, still has gaps. Most of the volume sharing DDEV used to depend on was removed upstream for ddev#8895 (ddev#8945, ddev#9024, ddev#8956, ddev#8944, ddev#9041, ddev#9042, ddev#9045). ddev#9040, ddev#9046, ddev#9061, ddev#9108, ddev#9115 and ddev#9121 also came out of this work. What's left is here.

## How This PR Solves The Issue

DDEV detects the provider through socktainer's `docker version` output (`IsAppleContainer()`). Every change below applies only on that provider.

- `ddev version`, `ddev utility dockercheck`, `ddev utility port-diagnose` and instrumentation report the provider as `apple-container`.
- `ddev start` and `ddev utility dockercheck` warn when socktainer is older than 1.6.1. Builds from source report no release version, so DDEV doesn't compare them.
- `ddev-ssh-agent` is always omitted, because web can't attach a volume another VM holds. With `ssh_agent_upstream` set, web bind-mounts that host socket directly, and Apple Container relays it into the VM. `host` uses `SSH_AUTH_SOCK`. `ddev auth ssh` explains this instead of adding keys to an agent web can't reach.
- `CopyIntoContainer` extracts with `tar` inside the container. socktainer 1.6.1 ignores a gzipped archive ([socktainer#484](socktainer/socktainer#484)) and drops each file's owner and mtime ([socktainer#514](socktainer/socktainer#514)). Both are fixed on socktainer `main` but not released.
- The mkcert CA archive leaves out its directory entry, which a never-started container refuses ([socktainer#502](socktainer/socktainer#502)).
- Project images build one service at a time. Concurrent image loads can leave a tag on its old image ([socktainer#518](socktainer/socktainer#518)), and Compose's bake build loads them all at once. Compose's concurrency limit doesn't reach the bake path, so DDEV calls `Build` once per service.
- Image pulls and `BuildPlatformToPull` use `linux/<arch>`, because socktainer's `/version` reports `Os: macOS` ([socktainer#517](socktainer/socktainer#517)).
- `host.docker.internal` is `host-gateway`, which socktainer resolves to the network gateway where the Mac answers.
- `FindContainersByVolume` matches `Mounts` itself, because socktainer ignores the `volume=` filter.
- Add-on installs get the same virtiofs propagation delay as Lima and Colima.
- Docs: an experimental Apple Container tab on the macOS Docker installation page, with setup, the Local Network prompt, SSH keys, limitations and a fix for a hanging `container system start`.

Mutagen works and is the default, as on any macOS provider.

Known limitations, each documented or named by a test skip:

- **Ports below 1024** can't be published. The router needs `ddev config global --router-http-port=8080 --router-https-port=8443`. The global setting matters: with 80/443 there, the router fails to bind even when the project sets 8080/8443.
- **Single-writer volumes:** add-on services that share a named volume with a running container fail to start. Apple closed [apple/container#1133](apple/container#1133) as working as designed.
- **Open socktainer issues:** [ddev#518](socktainer/socktainer#518), [ddev#519](socktainer/socktainer#519), [ddev#520](socktainer/socktainer#520), [ddev#517](socktainer/socktainer#517), [ddev#514](socktainer/socktainer#514), [ddev#510](socktainer/socktainer#510), [ddev#504](socktainer/socktainer#504), [ddev#499](socktainer/socktainer#499), [ddev#498](socktainer/socktainer#498), [ddev#497](socktainer/socktainer#497).
- **Unreleased socktainer fixes:** `main` has fixes for ddev#505, ddev#514, ddev#484 and ddev#498, the last still in PR [ddev#528](socktainer/socktainer#528). After the next release, a follow-up can raise `SocktainerMinVersion` and remove the matching skips and the `tar` workaround.
- socktainer 1.6.1 warns that it was built for Apple Container 1.6.1 when run with 1.7.1. The CI testbots run that pair, and it passes.

## Manual Testing Instructions

This needs macOS 26 on Apple silicon. The setup is in the new docs tab: https://ddev--8656.org.readthedocs.build/en/8656/users/install/docker-installation/

```bash
brew install socktainer docker docker-buildx
container system start
socktainer &
docker context use socktainer
ddev utility download-ddev --pr 8656
export PATH="$HOME/tmp/ddev-download-ddev/pr-8656:$PATH"
ddev config global --router-http-port=8080 --router-https-port=8443 --ssh-agent-upstream=host
mkdir -p ~/tmp/appletest && cd ~/tmp/appletest
echo '<?php echo gethostname();' > index.php
ddev config --project-type=php --docroot=.
ddev start -y
# Expect: macOS asks to allow container-runtime-linux on the local network the first time; click Allow
curl -s http://appletest.ddev.site:8080/
# Expect: appletest-web
ddev mutagen st -l | grep Status
# Expect: Status: Watching for changes
ddev exec ssh-add -l
# Expect: the keys that `ssh-add -l` lists on the host
ddev auth ssh
# Expect: an explanation that web uses the host's agent directly
ddev utility dockercheck
# Expect: socktainer version: 1.6.1
```

On another provider, run `ddev debug compose-config` in a project. Confirm that web still mounts `ddev-ssh-agent_socket_dir` and that `host.docker.internal` is unchanged.

## Automated Testing Overview

The Buildkite pipeline [macos-socktainer](https://buildkite.com/ddev/macos-socktainer) runs the suite with `DOCKER_TYPE=socktainer` and router ports 8080/8443. It runs on testbots with Apple Container 1.7.1 and socktainer 1.6.1. Build 40 passed on this branch before it was squashed.

- `TestAppleContainerSSHAgent` covers the host-agent mount. The `ddev-ssh-agent` tests skip there.
- Tests that hit a known socktainer or Apple Container gap skip on `IsAppleContainer()`, and each skip names its cause.
- `SkipUnlessDefaultEnvironment` still skips its tests there through its Mutagen check.

## Release/Deployment Notes

Apple Container support is experimental. The `macos-socktainer` pipeline builds only this branch, so its branch filter needs widening after merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rootless Docker: ddev start on a running project can leave router TLS keys unreadable

2 participants