Skip to content

fix: skip start-chown for volumes a running container holds, for #8895 (#9041) [skip ci] - #9041

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

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

Conversation

@rfay

@rfay rfay commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Dependencies: none.

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

Short Summary (TL;DR)

On ddev start, the start-chown helper no longer mounts volumes that a running container already holds. On Apple container that second attachment fails, and on every provider the chown has already been done.

Upgrading users start with empty bash and mysql history in each project: it is no longer copied from ddev-global-cache into the new project cache volumes.

The Issue

start-chown mounts ddev-global-cache, the database volume, and both project cache volumes on every ddev start. When the project is already running, its own containers hold those volumes. When any other project runs, its web container holds ddev-global-cache. Apple container refuses a second read-write attachment, so ddev start fails there in both cases.

How This PR Solves The Issue

  • New dockerutil.VolumesHeldByRunningContainers lists running containers once and returns which of the given volumes they mount. It reads Mounts instead of using the volume filter, so it does not depend on the API honoring that filter.
  • start-chown leaves out held volumes. A volume a running container holds was chowned when that container started.
  • chmod 1777 on ddev-global-cache runs only when nothing holds the volume. It already has that mode on any machine that started a project before.
  • A new project cache volume no longer gets bash and mysql history copied from ddev-global-cache/bashhistory and mysqlhistory, where DDEV kept it before feat: give web and db their own project cache volumes, for #8895 #9024. That copy was the only reason start-chown needed ddev-global-cache when another container held it, so start-chown now never attaches a held volume, read-only or otherwise.
  • When nothing is left to do, start-chown does not run at all. ddev start on a running project now skips it.

Manual Testing Instructions

ddev utility download-ddev --pr 9041
export PATH="$HOME/tmp/ddev-download-ddev/pr-9041:$PATH"
mkdir -p ~/tmp/b1 ~/tmp/b2
cd ~/tmp/b1 && ddev config --project-type=php && ddev start
DDEV_DEBUG=true ddev start 2>&1 | grep -E "Not chowning|start-chown"
# Expect three "Not chowning volume ..." lines and no start-chown container
cd ~/tmp/b2 && ddev config --project-type=php
DDEV_VERBOSE=true ddev start 2>&1 | grep "Exec .*chown"
# Expect no "chmod 1777", because b1 holds ddev-global-cache
ddev exec test -d /mnt/ddev-project-cache/history && echo ok
# Expect "ok"

Automated Testing Overview

TestVolumesHeldByRunningContainers checks a running container, a volume nothing mounts, and a stopped container. TestDdevStart and TestProjectCacheVolumes still pass. TestProjectCacheVolumes no longer seeds or checks copied history.

🤖 Developed with assistance from Claude Code

https://claude.ai/code/session_01UrTUMxNNNiQiA9QxsieVTQ


Generated by 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 9041

Or download the artifact for your OS and architecture directly:

See Testing a PR.

Open in GitHub Codespaces

claude and others added 2 commits November 2, 2026 07:59
…#8895

## Short Summary (TL;DR)

On `ddev start`, the `start-chown` helper no longer mounts volumes that a running container already holds. On Apple `container` that second attachment fails, and on every provider the chown has already been done.

## The Issue

- For ddev#8895 and ddev#7372

`start-chown` mounts `ddev-global-cache`, the database volume, and both project cache volumes on every `ddev start`. When the project is already running, its own containers hold those volumes. When any other project runs, its web container holds `ddev-global-cache`. Apple `container` refuses a second read-write attachment, so `ddev start` fails there in both cases.

## How This PR Solves The Issue

- New `dockerutil.VolumesHeldByRunningContainers` lists running containers once and returns which of the given volumes they mount. It reads `Mounts` instead of using the `volume` filter, so it does not depend on the API honoring that filter.
- `start-chown` leaves out held volumes. A volume a running container holds was chowned when that container started.
- `chmod 1777` on `ddev-global-cache` runs only when nothing holds the volume. It already has that mode on any machine that started a project before.
- A new project cache volume still gets its history copied from `ddev-global-cache`. When another container holds that volume, `start-chown` mounts it read-only for the copy.
- When nothing is left to do, `start-chown` does not run at all. `ddev start` on a running project now skips it.

## Manual Testing Instructions

```bash
ddev utility download-ddev --pr 9041
export PATH="$HOME/tmp/ddev-download-ddev/pr-9041:$PATH"
mkdir -p ~/tmp/b1 ~/tmp/b2
cd ~/tmp/b1 && ddev config --project-type=php && ddev start
DDEV_DEBUG=true ddev start 2>&1 | grep -E "Not chowning|start-chown"
# Expect three "Not chowning volume ..." lines and no start-chown container
docker exec ddev-b1-web bash -c 'mkdir -p /mnt/ddev-global-cache/bashhistory/b2-web && echo "echo OLD" > /mnt/ddev-global-cache/bashhistory/b2-web/bash_history'
cd ~/tmp/b2 && ddev config --project-type=php
DDEV_VERBOSE=true ddev start 2>&1 | grep "Exec .*chown"
# Expect no "chmod 1777", because b1 holds ddev-global-cache
ddev exec cat /mnt/ddev-project-cache/history/bash_history
# Expect "echo OLD": the history was copied through the read-only mount
```

## Automated Testing Overview

`TestVolumesHeldByRunningContainers` checks a running container, a volume nothing mounts, and a stopped container. `TestDdevStart` and `TestProjectCacheVolumes` still pass.

🤖 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


A new project cache volume no longer gets bash and mysql history copied
from ddev-global-cache/bashhistory and mysqlhistory, where older DDEV
versions kept it. History starts empty the first time a project starts on
this version; the old files stay in ddev-global-cache, unread.

Dropping the copy also drops the read-only ddev-global-cache mount that
start-chown needed for it when another container held that volume, so
start-chown no longer attaches a held volume in any mode.

TestProjectCacheVolumes no longer seeds or checks the copied history.

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

rfay commented Nov 2, 2026 •

Copy link
Copy Markdown
Member Author

Comment by Claude Code, at @rfay's request.

A new commit on this branch, "fix: drop the history copy into new project cache volumes", removes the one-time copy of bash and mysql history from ddev-global-cache/bashhistory and mysqlhistory into newly created project cache volumes. That copy came from #9024.

Why: The history isn't worth carrying over. The copy was also the only reason start-chown mounted ddev-global-cache read-only when another container held it, and nobody had tested that read-only attachment on Apple container. Without the copy, start-chown never attaches a volume that a running container holds, so this PR no longer depends on that behavior.

What users see: The first time a project starts after the upgrade, its bash and mysql history is empty. The old files stay in ddev-global-cache, and nothing reads them.

Changes:

  • pkg/ddevapp/ddevapp.go: removed newCacheServices, the cp -p step, and the ddev-global-cache:ro mount
  • pkg/ddevapp/project_cache_test.go: TestProjectCacheVolumes no longer seeds or checks copied history, and it still passes locally
  • The PR description and the manual test steps now match

Follow-up, not in this PR: containers/ddev-dbserver/files/docker-entrypoint.sh:265 still runs mkdir -p /mnt/ddev-global-cache/{bashhistory,mysqlhistory}/${HOSTNAME}. Since #9024, db containers keep their history in /mnt/ddev-project-cache/history/, so that line does nothing useful. Removing it means rebuilding the image and retagging, so it belongs in a separate change.

@rfay
rfay force-pushed the 20261101_rfay_start_chown_running branch from 9ed751e to b489eee Compare November 2, 2026 15:51
@rfay
rfay requested a review from stasadev November 2, 2026 15:55

@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 for me, one docs line to fix.

docs/content/users/usage/architecture.md still says the next ddev start copies old history from ddev-global-cache into the new volume. That's no longer true after the last commit. Maybe replace it with "Deleting the volume also deletes the project's shell history." or just drop it.

Claude Code ran ddev start on a running project and then started a second project on Docker: no start-chown for held volumes, no cp, no chmod, no global cache mount, and the new history directory starts empty. TestProjectCacheVolumes passes.

🤖 Reviewed with assistance from Claude Code

…for ddev#8895 [skip ci]

The previous commit stopped copying old history from ddev-global-cache
into a new project cache volume, so deleting the volume now just
deletes the project's shell history.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rfay
rfay requested a review from stasadev November 2, 2026 17:54
@rfay

rfay commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

Docs line fixed

@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 changed the title fix: skip start-chown for volumes a running container holds, for #8895 fix: skip start-chown for volumes a running container holds, for #8895 (#9041) [skip ci] Nov 2, 2026
@rfay
rfay merged commit 74f87fd into ddev:main Nov 2, 2026
10 checks passed
@rfay
rfay deleted the 20261101_rfay_start_chown_running branch November 2, 2026 22:47
rfay added a commit to rfay/ddev that referenced this pull request Nov 3, 2026
rfay added a commit to rfay/ddev that referenced this pull request Nov 3, 2026
rfay added a commit to rfay/ddev that referenced this pull request Nov 3, 2026
rfay added a commit to rfay/ddev that referenced this pull request Nov 3, 2026
rfay added a commit to rfay/ddev that referenced this pull request Nov 3, 2026
rfay added a commit to rfay/ddev that referenced this pull request Nov 4, 2026
rfay added a commit to rfay/ddev that referenced this pull request Nov 5, 2026
rfay added a commit to rfay/ddev that referenced this pull request Nov 6, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants