Skip to content

test: fail when a named volume has more than one writer, for #8895 - #9046

Merged
rfay merged 3 commits into
ddev:mainfrom
rfay:20261101_rfay_test_single_writer_volumes
Nov 3, 2026
Merged

rfay merged 3 commits into
ddev:mainfrom
rfay:20261101_rfay_test_single_writer_volumes

Conversation

@rfay

@rfay rfay commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

One of seven PRs for #8895, which can be reviewed separately: #9040, #9041, #9042, #9043, #9044, #9045, #9046.

Short Summary (TL;DR)

A new test renders two projects, the router, and the ssh-agent, then fails when a named volume is attached read-write by more than one service, or read-write by one and read-only by another. Docker allows both, but Apple container refuses them, so this catches a regression on any provider.

The Issue

The work in #8895 moves DDEV toward one writer per volume, but nothing stops a later change from sharing a volume again. Only a run on Apple container would show it.

How This PR Solves The Issue

TestNamedVolumesHaveOneWriter renders the compose files of two PHP projects, the router, and ddev-ssh-agent, with and without no_bind_mounts. It records each service's mounts by the volume's real name, so a volume shared across projects counts once. It needs Docker only to render the router compose file. It starts no containers.

The test sees only compose services, not the short-lived helper containers DDEV runs, for example the ones that mount ddev-global-cache.

knownSharedVolumes lists the volumes that are still shared today, each with its reason. Since #9043 and #9045 merged, only one is left:

  • ddev-ssh-agent_socket_dir, which needs a transport change and its own issue. The web containers and the agent all mount it read-write.

The test also fails when a listed volume is no longer shared, so whoever fixes the ssh-agent socket has to delete its entry, and the list can't go stale.

Manual Testing Instructions

make testpkg TESTARGS="-run TestNamedVolumesHaveOneWriter"
# Expect PASS
sed -i '/"ddev-ssh-agent_socket_dir": /d' pkg/ddevapp/volume_writers_internal_test.go
make testpkg TESTARGS="-run TestNamedVolumesHaveOneWriter"
# Expect a failure naming ddev-ssh-agent_socket_dir, the two web services, and ddev-ssh-agent

Automated Testing Overview

This PR is the test. It passes on current main.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

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

ddev utility download-ddev --pr 9046

Or download the artifact for your OS and architecture directly:

See Testing a PR.

Open in GitHub Codespaces

@rfay
rfay marked this pull request as draft November 2, 2026 14:25

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

Works, with one gap to close before merge, see the inline comments.

Small thing: the test only sees compose services, not the short-lived helper containers that mount ddev-global-cache. Maybe say so in the PR body.

Claude Code ran the test on the PR head on Docker, removing the ssh-agent entry, adding a web mount of snapshots, and making web's socket mount :ro. The first two fail as expected, and the third passes until the agent is rendered.

🤖 Reviewed with assistance from Claude Code

)

// knownSharedVolumes are the volumes still attached by more than one service
// in a way some providers refuse, with what keeps them that way. Keys ending

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.

The code checks strings.HasPrefix(key, "-"), so this should say keys starting with -.

claude and others added 2 commits November 3, 2026 05:55
## Short Summary (TL;DR)

A new test renders two projects and the router, then fails when a named volume is attached read-write by more than one service, or read-write by one and read-only by another. Docker allows both, but Apple `container` refuses them, so this catches a regression on any provider.

## The Issue

- For ddev#8895 and ddev#7372

The work in ddev#8895 moves DDEV toward one writer per volume, but nothing stops a later change from sharing a volume again. Only a run on Apple `container` would show it.

## How This PR Solves The Issue

`TestNamedVolumesHaveOneWriter` renders the compose files of two PHP projects and the router, with and without `no_bind_mounts`. It records each service's mounts by the volume's real name, so a volume shared across projects counts once. It needs Docker only to render the router compose file. It starts no containers.

`knownSharedVolumes` lists the volumes that are still shared today, each with its reason:

- `ddev-global-cache`, until ddev#9045 lands
- `<project>-ddev-config` with `no_bind_mounts`, until ddev#9043 lands
- `ddev-ssh-agent_socket_dir`, which needs a transport change and its own issue

The test also fails when a listed volume is no longer shared. So whichever of ddev#9043, ddev#9045 and this PR merges last has to delete its entry, and the list can't go stale.

## Manual Testing Instructions

```bash
make testpkg TESTARGS="-run TestNamedVolumesHaveOneWriter"
# Expect PASS
sed -i '/"ddev-ssh-agent_socket_dir": /d' pkg/ddevapp/volume_writers_internal_test.go
make testpkg TESTARGS="-run TestNamedVolumesHaveOneWriter"
# Expect a failure naming ddev-ssh-agent_socket_dir and the two web services
```

## Automated Testing Overview

This PR is the test. With ddev#9043 and ddev#9045 applied, it fails until their two entries come out of `knownSharedVolumes`, then it passes.

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UrTUMxNNNiQiA9QxsieVTQ
…dev#8895

The agent's own read-write mount of ddev-ssh-agent_socket_dir was invisible
to the test, so making web's mount read-only would have passed while the
agent still wrote to the volume.

ddev-global-cache and <project>-ddev-config are no longer shared since
ddev#9045 and ddev#9043, so their entries and the suffix matching go away.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rfay
rfay force-pushed the 20261101_rfay_test_single_writer_volumes branch from bfacc65 to 6f26939 Compare November 3, 2026 13:11
@rfay
rfay marked this pull request as ready for review November 3, 2026 16:09
@rfay
rfay requested a review from stasadev November 3, 2026 16:09

@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. The ssh-agent is rendered now, which closes the gap from my last review.

Small thing, optional: the stale-entry check runs only under if noBindMounts, which was there for the -ddev-config entry. The socket is shared in both modes, so that guard could go.

…p ci], for ddev#8895

The noBindMounts guard was only needed for the -ddev-config entry, which
is gone. The ssh-agent socket volume is shared in both modes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rfay
rfay merged commit da4085f into ddev:main Nov 3, 2026
5 of 8 checks passed
@rfay
rfay deleted the 20261101_rfay_test_single_writer_volumes branch November 3, 2026 23:11
rfay added a commit to rfay/ddev that referenced this pull request Nov 6, 2026
…[skip github]

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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

Records the 2026-11-06 rebase, socktainer#492, ddev#494 and ddev#496 merged but unreleased, ddev#9046 and ddev#9061 merged, the split-out test-fix branch, and what remains before review.

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.

3 participants