Skip to content

refactor(mutagen): mount project_mutagen once, chown around bind mounts, for #8895 - #8944

Merged
rfay merged 2 commits into
mainfrom
20261014_rfay_mutagen_single_mount
Oct 15, 2026
Merged

rfay merged 2 commits into
mainfrom
20261014_rfay_mutagen_single_mount

Conversation

@rfay

@rfay rfay commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

The web container now mounts the Mutagen volume only at /var/www, instead of a second time at /tmp/project_mutagen just so it could be chowned. The chown runs on /var/www and skips every mount point beneath it, so the user's bind-mounted host files are never touched.

The Issue

Mounting one volume twice in a container is a second attachment that providers like Apple container may not allow. The second mount existed only to give chown -R a view of the volume without the upload_dirs, .git and custom compose bind mounts on top of it, because chowning through those would change ownership of the user's host files.

How This PR Solves The Issue

SetMutagenVolumeOwnership reads the mount points under /var/www/ from /proc/self/mountinfo and passes each one to find as -prune, then chowns everything else. find -xdev, suggested in #8895, is not enough: on native Linux the volume in /var/lib/docker and a bind-mounted project in the home directory are often on the same filesystem, so they report the same device and -xdev walks straight into .git and the upload dirs. That was confirmed on Ubuntu 26.04 with Docker CE, where every path reported the same st_dev.

Dead end: chowning in a transient container before start

The first attempt dropped the in-container chown and added the Mutagen volume to the existing start-chown-* utilities container, which already chowns ddev-global-cache and the database volume before compose up. With no bind mounts in that container, a plain chown -R would have been safe, and it would have run alongside the compose build instead of after start.

It broke a project's first start. When the web container starts, Docker creates any missing working_dir and bind-mount parent directories inside the volume as root, so on a new volume /var/www/html, web/, web/sites/ and so on came out owned by 0:0 after the chown had already run. Mutagen, running as the user, then failed with unable to create directory: permission denied, while ddev start still reported success. Existing projects looked fine only because earlier starts had already created those directories. This is the long-standing Docker behavior of creating missing mount points as root, so the chown has to run after the container starts, as it did before.

Manual Testing Instructions

On native Linux Docker, where /var/lib/docker and the project are on the same filesystem:

ddev utility download-ddev --pr 8944
export PATH="$HOME/tmp/ddev-download-ddev/pr-8944:$PATH"
mkdir -p ~/tmp/mutchown/web/sites/default/files && cd ~/tmp/mutchown && git init
echo hi > web/index.php
ddev config --project-type=php --docroot=web --upload-dirs=sites/default/files --performance-mode=mutagen
ddev start
# Expect a clean sync, and /var/www/html and its parents owned by your uid
ddev exec "stat -c '%u:%g %n' /var/www/html /var/www/html/web/sites/default /var/www/html/web/index.php"
ddev exec -u root "touch /var/www/html/rootfile; chown 4444:4444 /var/www/html/.git/config /var/www/html/web/sites/default/files"
ddev restart
# Expect rootfile owned by your uid, the two bind-mounted paths still 4444, and no /tmp/project_mutagen
ddev exec "stat -c '%u:%g %n' /var/www/html/rootfile /var/www/html/.git/config /var/www/html/web/sites/default/files; ls /tmp/project_mutagen"

Automated Testing Overview

The existing Mutagen tests in pkg/ddevapp cover sync and ownership. There is no new test, because the case this protects against needs native Linux with the project and Docker's volumes on the same filesystem, which the test runners do not set up deliberately.

Release/Deployment Notes

Existing projects pick up the change when ddev start regenerates the compose file; the volume and its contents are unchanged.

🤖 Developed with assistance from Claude Code

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

…ts, for #8895

## Short Summary (TL;DR)

The web container now mounts the Mutagen volume only at `/var/www`, instead of a second time at `/tmp/project_mutagen` just so it could be chowned. The chown runs on `/var/www` and skips every mount point beneath it, so the user's bind-mounted host files are never touched.

## The Issue

- For #8895, and toward #7372

Mounting one volume twice in a container is a second attachment that providers like Apple container may not allow, and it existed only to give `chown -R` a view of the volume without the upload_dirs, `.git` and custom compose bind mounts on top.

## How This PR Solves The Issue

`SetMutagenVolumeOwnership` reads the mount points under `/var/www/` from `/proc/self/mountinfo` and passes each to `find` as `-prune`, then chowns everything else. `find -xdev` was not enough, because on native Linux the volume and the bind mounts often share a device, so `-xdev` walks into the host files.

The chown still runs in web after start rather than in a transient container before it, because Docker creates a missing `working_dir` and bind-mount parent directories in the volume as root when the container starts. A pre-start chown left a fresh project's `/var/www/html` root-owned, and Mutagen then could not sync into it.

## Manual Testing Instructions

On native Linux Docker, where `/var/lib/docker` and the project are on the same filesystem:

```bash
ddev utility download-ddev --pr 8943
export PATH="$HOME/tmp/ddev-download-ddev/pr-8943:$PATH"
mkdir -p ~/tmp/mutchown/web/sites/default/files && cd ~/tmp/mutchown && git init
echo hi > web/index.php
ddev config --project-type=php --docroot=web --upload-dirs=sites/default/files --performance-mode=mutagen
ddev start
# Expect a clean sync, and /var/www/html and its parents owned by your uid
ddev exec "stat -c '%u:%g %n' /var/www/html /var/www/html/web/sites/default /var/www/html/web/index.php"
ddev exec -u root "touch /var/www/html/rootfile; chown 4444:4444 /var/www/html/.git/config /var/www/html/web/sites/default/files"
ddev restart
# Expect rootfile owned by your uid, the two bind-mounted paths still 4444, and no /tmp/project_mutagen
ddev exec "stat -c '%u:%g %n' /var/www/html/rootfile /var/www/html/.git/config /var/www/html/web/sites/default/files; ls /tmp/project_mutagen"
```

## Automated Testing Overview

The existing Mutagen tests cover sync and ownership; `TestMutagenConfigChange` passes locally.

## Release/Deployment Notes

Existing projects pick up the change when `ddev start` regenerates the compose file; the volume and its contents are unchanged.

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rfay
rfay requested a review from a team as a code owner October 14, 2026 16:15
@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 8944

Or download the artifact for your OS and architecture directly:

See Testing a PR.

Open in GitHub Codespaces

@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 the manual test on native Linux, where Docker's volumes and the project are on the same filesystem. .git/config, sites/default/files and an upload dir with a space in its name kept their 4444 owner, /tmp/project_mutagen is gone, and sync is clean. One problem with upload dirs whose names have glob characters, see inline.

🤖 Developed with assistance from Claude Code

Comment thread pkg/ddevapp/mutagen.go Resolved
Co-authored-by: Stanislav Zhuk <[email protected]>
@stasadev
stasadev self-requested a review October 14, 2026 16:32

@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 c86501a into main Oct 15, 2026
50 checks passed
@rfay
rfay deleted the 20261014_rfay_mutagen_single_mount branch October 15, 2026 03:08
rfay added a commit to rfay/ddev that referenced this pull request Nov 2, 2026
Mutagen was forced off on apple container because web mounted
project_mutagen twice, and apple container can't attach one block
volume twice in a VM. Upstream ddev#8944 reduced that to a single mount at
/var/www, so the restriction, the no_bind_mounts warning and the Mutagen
test skips are dropped, and Mutagen is the default as on any macOS
provider.

Tested on socktainer: sync in both directions, upload_dirs as a
virtiofs mount inside the project_mutagen volume, restart and
stop/start, and TestMutagenConfigChange, TestMutagenDiagnose and
TestCmdMutagen passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Nov 3, 2026
Mutagen was forced off on apple container because web mounted
project_mutagen twice, and apple container can't attach one block
volume twice in a VM. Upstream ddev#8944 reduced that to a single mount at
/var/www, so the restriction, the no_bind_mounts warning and the Mutagen
test skips are dropped, and Mutagen is the default as on any macOS
provider.

Tested on socktainer: sync in both directions, upload_dirs as a
virtiofs mount inside the project_mutagen volume, restart and
stop/start, and TestMutagenConfigChange, TestMutagenDiagnose and
TestCmdMutagen passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Nov 3, 2026
Mutagen was forced off on apple container because web mounted
project_mutagen twice, and apple container can't attach one block
volume twice in a VM. Upstream ddev#8944 reduced that to a single mount at
/var/www, so the restriction, the no_bind_mounts warning and the Mutagen
test skips are dropped, and Mutagen is the default as on any macOS
provider.

Tested on socktainer: sync in both directions, upload_dirs as a
virtiofs mount inside the project_mutagen volume, restart and
stop/start, and TestMutagenConfigChange, TestMutagenDiagnose and
TestCmdMutagen passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Nov 3, 2026
Mutagen was forced off on apple container because web mounted
project_mutagen twice, and apple container can't attach one block
volume twice in a VM. Upstream ddev#8944 reduced that to a single mount at
/var/www, so the restriction, the no_bind_mounts warning and the Mutagen
test skips are dropped, and Mutagen is the default as on any macOS
provider.

Tested on socktainer: sync in both directions, upload_dirs as a
virtiofs mount inside the project_mutagen volume, restart and
stop/start, and TestMutagenConfigChange, TestMutagenDiagnose and
TestCmdMutagen passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Nov 3, 2026
Mutagen was forced off on apple container because web mounted
project_mutagen twice, and apple container can't attach one block
volume twice in a VM. Upstream ddev#8944 reduced that to a single mount at
/var/www, so the restriction, the no_bind_mounts warning and the Mutagen
test skips are dropped, and Mutagen is the default as on any macOS
provider.

Tested on socktainer: sync in both directions, upload_dirs as a
virtiofs mount inside the project_mutagen volume, restart and
stop/start, and TestMutagenConfigChange, TestMutagenDiagnose and
TestCmdMutagen passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Nov 3, 2026
Mutagen was forced off on apple container because web mounted
project_mutagen twice, and apple container can't attach one block
volume twice in a VM. Upstream ddev#8944 reduced that to a single mount at
/var/www, so the restriction, the no_bind_mounts warning and the Mutagen
test skips are dropped, and Mutagen is the default as on any macOS
provider.

Tested on socktainer: sync in both directions, upload_dirs as a
virtiofs mount inside the project_mutagen volume, restart and
stop/start, and TestMutagenConfigChange, TestMutagenDiagnose and
TestCmdMutagen passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Nov 4, 2026
Mutagen was forced off on apple container because web mounted
project_mutagen twice, and apple container can't attach one block
volume twice in a VM. Upstream ddev#8944 reduced that to a single mount at
/var/www, so the restriction, the no_bind_mounts warning and the Mutagen
test skips are dropped, and Mutagen is the default as on any macOS
provider.

Tested on socktainer: sync in both directions, upload_dirs as a
virtiofs mount inside the project_mutagen volume, restart and
stop/start, and TestMutagenConfigChange, TestMutagenDiagnose and
TestCmdMutagen passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Nov 5, 2026
Mutagen was forced off on apple container because web mounted
project_mutagen twice, and apple container can't attach one block
volume twice in a VM. Upstream ddev#8944 reduced that to a single mount at
/var/www, so the restriction, the no_bind_mounts warning and the Mutagen
test skips are dropped, and Mutagen is the default as on any macOS
provider.

Tested on socktainer: sync in both directions, upload_dirs as a
virtiofs mount inside the project_mutagen volume, restart and
stop/start, and TestMutagenConfigChange, TestMutagenDiagnose and
TestCmdMutagen passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Nov 6, 2026
Mutagen was forced off on apple container because web mounted
project_mutagen twice, and apple container can't attach one block
volume twice in a VM. Upstream ddev#8944 reduced that to a single mount at
/var/www, so the restriction, the no_bind_mounts warning and the Mutagen
test skips are dropped, and Mutagen is the default as on any macOS
provider.

Tested on socktainer: sync in both directions, upload_dirs as a
virtiofs mount inside the project_mutagen volume, restart and
stop/start, and TestMutagenConfigChange, TestMutagenDiagnose and
TestCmdMutagen passing.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants