Skip to content

feat: give web and db their own project cache volumes, for #8895 - #9024

Merged
rfay merged 7 commits into
ddev:mainfrom
rfay:20261027_rfay_project_cache_volumes
Oct 29, 2026
Merged

rfay merged 7 commits into
ddev:mainfrom
rfay:20261027_rfay_project_cache_volumes

Conversation

@rfay

@rfay rfay commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

Each project now gets ddev-<project>-web-cache and ddev-<project>-db-cache volumes, mounted at /mnt/ddev-project-cache. Shell history and the package caches move there from ddev-global-cache, and DDEV no longer chowns the whole ddev-global-cache volume.

The Issue

Sharing caches across projects caused accidental problems. For example, the terminus cache carried one project's Pantheon login into other projects. Every project start also ran chown -R on the whole shared volume, so two users or user namespaces fought over its ownership.

How This PR Solves The Issue

  • The web volume holds history/, composer, npm, yarn, corepack, pip, terminus/cache, and n_prefix.
  • The db volume holds history/.
  • Start sets ddev-global-cache to mode 1777 and doesn't chown it recursively. Only the files DDEV copies into it, such as mkcert and traefik, get the host user's ownership.
  • When a cache volume is first created, start copies the old bash and MySQL history into it. Caches start cold.
  • ddev delete removes both volumes.
  • Web still mounts ddev-global-cache at the same path, so add-ons that use it keep working.

This replaces #8947 and #8964, which moved only history.

Relationship to #8956

#8956 moves global commands out of ddev-global-cache and copies them into each container, including custom services. This PR doesn't touch global commands, so the two PRs don't overlap there. Web and db still run global commands from /mnt/ddev-global-cache/global-commands, as on main.

The one connection is db's mount. db needs ddev-global-cache only for its global commands, such as ddev mysql and ddev psql. This PR mounts it read-only in db, because db no longer writes there. Once #8956 lands, db doesn't need the mount at all, so whichever PR merges second should remove it.

Both PRs change the start-time chown code in pkg/ddevapp/ddevapp.go and docs/content/users/usage/architecture.md, so the second one to merge needs a rebase.

Manual Testing Instructions

ddev utility download-ddev --pr 9024
export PATH="$HOME/tmp/ddev-download-ddev/pr-9024:$PATH"
ddev config --project-type=drupal11 --docroot=web
ddev start
docker volume ls | grep -- -cache
# Expect ddev-<project>-web-cache and ddev-<project>-db-cache
ddev exec 'echo $COMPOSER_CACHE_DIR $npm_config_cache'
# Expect /mnt/ddev-project-cache/composer /mnt/ddev-project-cache/npm
ddev mysql -e 'select 1'
ddev exec -s db touch /mnt/ddev-global-cache/x
# Expect "Read-only file system"
ddev delete -Oy
docker volume ls | grep -- -cache
# Expect no volumes for the project

Changed docs: https://ddev--9024.org.readthedocs.build/en/9024/users/usage/architecture/#project-cache-volumes

Automated Testing Overview

TestProjectCacheVolumes checks the volumes, the env paths, history migration and persistence, db's read-only mount, and the removal by ddev delete.

Release/Deployment Notes

The first Composer or npm install in each project downloads everything again. The old caches and history stay in ddev-global-cache for now, so a downgrade still finds them. The cleanup plan is in #8895 (comment).

🤖 Generated with Claude Code

@rfay
rfay requested a review from a team as a code owner October 27, 2026 18:22
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file enhancement labels Oct 27, 2026
@rfay
rfay force-pushed the 20261027_rfay_project_cache_volumes branch from 944b19d to 020f88e Compare October 27, 2026 18:27
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

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

ddev utility download-ddev --pr 9024

Or download the artifact for your OS and architecture directly:

See Testing a PR.

Open in GitHub Codespaces

@github-actions

Copy link
Copy Markdown

Pushed updated container image(s) for this PR:

  • ddev/ddev-webserver-prod:b436490640
  • ddev/ddev-webserver:b436490640

@github-actions

Copy link
Copy Markdown

Pushed updated container image(s) for this PR:

  • ddev/ddev-webserver-prod:37563824d8
  • ddev/ddev-webserver:37563824d8

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

I only have minor suggestions.

@rfay
rfay force-pushed the 20261027_rfay_project_cache_volumes branch from 54665ee to fd85e73 Compare October 28, 2026 20:48
@github-actions

Copy link
Copy Markdown

Pushed updated container image(s) for this PR:

  • ddev/ddev-webserver-prod:d96dde43c6
  • ddev/ddev-webserver:d96dde43c6

rfay and others added 7 commits October 28, 2026 15:59
Each project now gets `<project>-web-cache` and `<project>-db-cache` volumes, mounted at `/mnt/ddev-project-cache`. Shell history and the package caches move there from `ddev-global-cache`, and DDEV no longer chowns the shared volume.

- For ddev#8895

Sharing caches across projects caused accidental problems. For example, the terminus cache carried one project's Pantheon login into other projects. Every project start also ran `chown -R` on the whole shared volume, so two users or user namespaces fought over its ownership.

- The web volume holds `history/`, `composer`, `npm`, `yarn`, `corepack`, `pip`, `terminus/cache`, and `n_prefix`. The db volume holds `history/` and a copy of the db global commands.
- db no longer mounts `ddev-global-cache`. Start copies `global-commands/db` into the db volume, and `ddev mysql`, `ddev psql`, and other db global commands run from there.
- Start sets `ddev-global-cache` to mode 1777 and never chowns it. It chowns only the project volumes.
- When a cache volume is first created, start copies the old bash and MySQL history into it. Caches start cold.
- `ddev delete` removes both volumes.
- Web still mounts `ddev-global-cache` at the same path, so add-ons that use it keep working.

This replaces ddev#8947 and ddev#8964, which moved only history.

```bash
ddev utility download-ddev --pr 9024
export PATH="$HOME/tmp/ddev-download-ddev/pr-9024:$PATH"
ddev config --project-type=drupal11 --docroot=web
ddev start
docker volume ls | grep -- -cache
ddev exec 'echo $COMPOSER_CACHE_DIR $npm_config_cache'
ddev mysql -e 'select 1'
ddev exec -s db 'grep ddev-global-cache /proc/mounts || echo none'
ddev delete -Oy
docker volume ls | grep -- -cache
```

Changed docs: https://ddev--9024.org.readthedocs.build/en/9024/users/usage/architecture/#project-cache-volumes

`TestProjectCacheVolumes` checks the volumes, the env paths, history migration and persistence, the db global commands, and the removal by `ddev delete`.

The first Composer or npm install in each project downloads everything again. Old caches stay in `ddev-global-cache` until the user removes that volume.

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ache volumes with ddev-, for ddev#8895

Start now copies the web global commands into web's project cache volume, as it already does for db. Web runs them from /mnt/ddev-project-cache/global-commands, and its PATH fallback points there. Custom services still run global commands from ddev-global-cache.

The cache volumes are now named ddev-<project>-web-cache and ddev-<project>-db-cache, so they are easy to identify.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…che read-only in db, for ddev#8895

The docs now name v1.26.0 as the release that moves caches and history out of ddev-global-cache.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rfay
rfay force-pushed the 20261027_rfay_project_cache_volumes branch from fd85e73 to 1a59801 Compare October 28, 2026 22:10
@github-actions

Copy link
Copy Markdown

Pushed updated container image(s) for this PR:

  • ddev/ddev-webserver-prod:323aad0f1a
  • ddev/ddev-webserver:323aad0f1a

@rfay
rfay merged commit a90b98e into ddev:main Oct 29, 2026
54 of 56 checks passed
@rfay
rfay deleted the 20261027_rfay_project_cache_volumes branch October 29, 2026 02:30
rfay pushed a commit to rfay/ddev that referenced this pull request Nov 2, 2026
…l-cache, for ddev#8895

## Short Summary (TL;DR)

DDEV now copies the host's mkcert root CA into the web container on start, and web and db no longer mount `ddev-global-cache`. This removes the last volume DDEV's own containers share across projects. **Add-ons that write to `/mnt/ddev-global-cache` from web are affected; see below.**

## The Issue

- For ddev#8895 and ddev#7372

Web mounted `ddev-global-cache` read-write in every project, and db mounted it read-only, mainly so web could read the mkcert CA at `/mnt/ddev-global-cache/mkcert`. Apple `container` allows one read-write attachment of a volume, so even two projects could not run at once there. Since ddev#9024 and ddev#8956 moved package caches, history, and global commands out of the volume, the CA was the only thing DDEV still needed from it.

## How This PR Solves The Issue

- Right after compose starts the containers, `copyCAROOTIntoWeb` copies `rootCA.pem` and `rootCA-key.pem` into web at `/mnt/ddev-global-cache/mkcert`, the existing `CAROOT`. It uses one tar, like ddev#8956 does for global commands, owned by the container user. The last entry is an empty `.ddev-copied` marker.
- When the host has a CA, web gets `DDEV_WAIT_FOR_CAROOT=true`. Web's `start.sh` then waits up to 60 seconds for the marker before it runs `mkcert`. Without the wait, mkcert would create its own CA in the empty directory and sign web's certificate with it.
- Web and db no longer mount `ddev-global-cache`. The compose file still declares the volume, so add-on services keep mounting it. DDEV still fills `ddev-global-cache/mkcert` for add-on images that read `CAROOT` from there.

## For discussion: add-ons that use the volume from web

Several add-ons write to `/mnt/ddev-global-cache` from the web container without mounting it themselves: `ddev-nvm` (`nvm_dir`), `ddev-pnpm` (`PNPM_HOME`), `ddev-platformsh` and `ddev-upsun` (`PLATFORM_CACHE_DIR`). After this change their data lives in the container, so a `ddev restart` loses it. Nothing fails outright: `ddev-nvm` extracts its copy from the image again on each start. Each add-on can get the old behavior back with three lines in its `docker-compose.*.yaml`. The architecture docs now show them:

```yaml
services:
  web:
    volumes:
      - ddev-global-cache:/mnt/ddev-global-cache
```

That brings back a shared read-write volume for users of those add-ons, but only for them. The alternative is to keep web's mount and copy the CA anyway. That keeps the add-ons working but leaves Apple `container` unable to run two projects.

## Manual Testing Instructions

```bash
ddev utility download-ddev --pr 9045
export PATH="$HOME/tmp/ddev-download-ddev/pr-9045:$PATH"
mkdir -p ~/tmp/f1 && cd ~/tmp/f1
ddev config --project-type=php
ddev start
docker inspect -f '{{range .Mounts}}{{.Name}} {{end}}' ddev-f1-web ddev-f1-db
# Expect no ddev-global-cache
ddev exec 'openssl verify -CAfile $CAROOT/rootCA.pem /etc/ssl/certs/master.crt'
# Expect "OK": web signed its certificate with the host's CA
ddev exec curl -sI https://f1.ddev.site | head -1
# Expect HTTP 200 with no certificate error
ddev restart && ddev exec curl -sI https://f1.ddev.site | head -1
```

## Automated Testing Overview

- `TestCARootArchive` checks the archive's order, ownership, and modes.
- `TestWebCAROOTCopied` starts a project and checks several things: web and db don't mount `ddev-global-cache`, web's CA matches the host's, the container user owns the key with mode 600, and `openssl verify` accepts `master.crt`.
- `TestProjectCacheVolumes` no longer checks that db's `ddev-global-cache` mount is read-only.

## Release/Deployment Notes

Add-on maintainers whose web-side scripts write to `/mnt/ddev-global-cache` need to add the mount shown above.

🤖 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
rfay pushed a commit to rfay/ddev that referenced this pull request Nov 2, 2026
…ev#8895

## Short Summary (TL;DR)

`ddev stop` and `ddev delete` now remove the project's router files with an exec in the running router instead of a helper container. The sweep of old per-container directories in `ddev-global-cache` now runs after the project's containers are gone, and only when nothing else holds that volume.

## The Issue

- For ddev#8895 and ddev#7372

`ddev stop` started `remove-project-merged-config`, and `ddev delete` started `clean-ddev-global-cache`. Both mounted `ddev-router-traefik` while the router held it. The second also mounted `ddev-global-cache` read-write while web containers held it. Apple `container` refuses a second read-write attachment, so these cleanups failed there. They also left an empty `traefik` mountpoint in `ddev-global-cache`.

## How This PR Solves The Issue

- New `removeRouterTraefikFiles` runs `rm -rf` through `dockerutil.Exec` when the router runs, as `PushGlobalTraefikConfig` already does. It uses a helper container only when the router is stopped.
- New `removeOldGlobalCacheData` removes `/mnt/ddev-global-cache/*/<project>-{web,db}`, the history and `n_prefix` directories from before ddev#9024. It runs after `Cleanup()`, so the project's own web no longer holds the volume. While any other running container holds `ddev-global-cache`, it skips the removal and logs that at debug level. Those directories are a few KB, and a later `ddev delete` with no running project removes them.

## Manual Testing Instructions

```bash
ddev utility download-ddev --pr 9042
export PATH="$HOME/tmp/ddev-download-ddev/pr-9042:$PATH"
mkdir -p ~/tmp/c1 ~/tmp/c2
cd ~/tmp/c1 && ddev config --project-type=php && ddev start
cd ~/tmp/c2 && ddev config --project-type=php && ddev start
docker exec ddev-c2-web mkdir -p /mnt/ddev-global-cache/bashhistory/c1-web /mnt/ddev-global-cache/bashhistory/c2-web
cd ~/tmp/c1 && DDEV_DEBUG=true ddev delete -Oy 2>&1 | grep -E "router files|Not cleaning"
# Expect the rm through the router, then "Not cleaning ddev-global-cache", because c2 holds it
docker exec ddev-router ls /mnt/ddev-global-cache/traefik/config /mnt/ddev-global-cache/traefik/certs
# Expect no c1 files
cd ~/tmp/c2 && ddev delete -Oy
docker run --rm -v ddev-global-cache:/m ddev/ddev-utilities ls /m/bashhistory
# Expect c2-web gone; c1-web stays from the first delete
```

Run `docker events --filter event=create` in another terminal during `ddev stop`. Expect no `remove-project-merged-config` or `remove-router-files` container while the router runs.

## Automated Testing Overview

New `TestStopRemovesRouterFiles` stops a project while another keeps the router running, and checks that the merged config is gone and the certs stay. It then removes data and checks that the certs are gone. It guards behavior that already worked on Docker. `TestStopRemoveData*` and `TestDeleteCmd` 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
rfay pushed a commit to rfay/ddev that referenced this pull request Nov 2, 2026
…l-cache, for ddev#8895

## Short Summary (TL;DR)

DDEV now copies the host's mkcert root CA into the web container on start, and web and db no longer mount `ddev-global-cache`. This removes the last volume DDEV's own containers share across projects. **Add-ons that write to `/mnt/ddev-global-cache` from web are affected; see below.**

## The Issue

- For ddev#8895 and ddev#7372

Web mounted `ddev-global-cache` read-write in every project, and db mounted it read-only, mainly so web could read the mkcert CA at `/mnt/ddev-global-cache/mkcert`. Apple `container` allows one read-write attachment of a volume, so even two projects could not run at once there. Since ddev#9024 and ddev#8956 moved package caches, history, and global commands out of the volume, the CA was the only thing DDEV still needed from it.

## How This PR Solves The Issue

- Right after compose starts the containers, `copyCAROOTIntoWeb` copies `rootCA.pem` and `rootCA-key.pem` into web at `/mnt/ddev-global-cache/mkcert`, the existing `CAROOT`. It uses one tar, like ddev#8956 does for global commands, owned by the container user. The last entry is an empty `.ddev-copied` marker.
- When the host has a CA, web gets `DDEV_WAIT_FOR_CAROOT=true`. Web's `start.sh` then waits up to 60 seconds for the marker before it runs `mkcert`. Without the wait, mkcert would create its own CA in the empty directory and sign web's certificate with it.
- Web and db no longer mount `ddev-global-cache`. The compose file still declares the volume, so add-on services keep mounting it. DDEV still fills `ddev-global-cache/mkcert` for add-on images that read `CAROOT` from there.

## For discussion: add-ons that use the volume from web

Several add-ons write to `/mnt/ddev-global-cache` from the web container without mounting it themselves: `ddev-nvm` (`nvm_dir`), `ddev-pnpm` (`PNPM_HOME`), `ddev-platformsh` and `ddev-upsun` (`PLATFORM_CACHE_DIR`). After this change their data lives in the container, so a `ddev restart` loses it. Nothing fails outright: `ddev-nvm` extracts its copy from the image again on each start. Each add-on can get the old behavior back with three lines in its `docker-compose.*.yaml`. The architecture docs now show them:

```yaml
services:
  web:
    volumes:
      - ddev-global-cache:/mnt/ddev-global-cache
```

That brings back a shared read-write volume for users of those add-ons, but only for them. The alternative is to keep web's mount and copy the CA anyway. That keeps the add-ons working but leaves Apple `container` unable to run two projects.

## Manual Testing Instructions

```bash
ddev utility download-ddev --pr 9045
export PATH="$HOME/tmp/ddev-download-ddev/pr-9045:$PATH"
mkdir -p ~/tmp/f1 && cd ~/tmp/f1
ddev config --project-type=php
ddev start
docker inspect -f '{{range .Mounts}}{{.Name}} {{end}}' ddev-f1-web ddev-f1-db
# Expect no ddev-global-cache
ddev exec 'openssl verify -CAfile $CAROOT/rootCA.pem /etc/ssl/certs/master.crt'
# Expect "OK": web signed its certificate with the host's CA
ddev exec curl -sI https://f1.ddev.site | head -1
# Expect HTTP 200 with no certificate error
ddev restart && ddev exec curl -sI https://f1.ddev.site | head -1
```

## Automated Testing Overview

- `TestCARootArchive` checks the archive's order, ownership, and modes.
- `TestWebCAROOTCopied` starts a project and checks several things: web and db don't mount `ddev-global-cache`, web's CA matches the host's, the container user owns the key with mode 600, and `openssl verify` accepts `master.crt`.
- `TestProjectCacheVolumes` no longer checks that db's `ddev-global-cache` mount is read-only.

## Release/Deployment Notes

Add-on maintainers whose web-side scripts write to `/mnt/ddev-global-cache` need to add the mount shown above.

🤖 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
rfay pushed a commit to rfay/ddev that referenced this pull request Nov 3, 2026
…l-cache, for ddev#8895

## Short Summary (TL;DR)

DDEV now copies the host's mkcert root CA into the web container on start, and web and db no longer mount `ddev-global-cache`. This removes the last volume DDEV's own containers share across projects. **Add-ons that write to `/mnt/ddev-global-cache` from web are affected; see below.**

## The Issue

- For ddev#8895 and ddev#7372

Web mounted `ddev-global-cache` read-write in every project, and db mounted it read-only, mainly so web could read the mkcert CA at `/mnt/ddev-global-cache/mkcert`. Apple `container` allows one read-write attachment of a volume, so even two projects could not run at once there. Since ddev#9024 and ddev#8956 moved package caches, history, and global commands out of the volume, the CA was the only thing DDEV still needed from it.

## How This PR Solves The Issue

- Right after compose starts the containers, `copyCAROOTIntoWeb` copies `rootCA.pem` and `rootCA-key.pem` into web at `/mnt/ddev-global-cache/mkcert`, the existing `CAROOT`. It uses one tar, like ddev#8956 does for global commands, owned by the container user. The last entry is an empty `.ddev-copied` marker.
- When the host has a CA, web gets `DDEV_WAIT_FOR_CAROOT=true`. Web's `start.sh` then waits up to 60 seconds for the marker before it runs `mkcert`. Without the wait, mkcert would create its own CA in the empty directory and sign web's certificate with it.
- Web and db no longer mount `ddev-global-cache`. The compose file still declares the volume, so add-on services keep mounting it. DDEV still fills `ddev-global-cache/mkcert` for add-on images that read `CAROOT` from there.

## For discussion: add-ons that use the volume from web

Several add-ons write to `/mnt/ddev-global-cache` from the web container without mounting it themselves: `ddev-nvm` (`nvm_dir`), `ddev-pnpm` (`PNPM_HOME`), `ddev-platformsh` and `ddev-upsun` (`PLATFORM_CACHE_DIR`). After this change their data lives in the container, so a `ddev restart` loses it. Nothing fails outright: `ddev-nvm` extracts its copy from the image again on each start. Each add-on can get the old behavior back with three lines in its `docker-compose.*.yaml`. The architecture docs now show them:

```yaml
services:
  web:
    volumes:
      - ddev-global-cache:/mnt/ddev-global-cache
```

That brings back a shared read-write volume for users of those add-ons, but only for them. The alternative is to keep web's mount and copy the CA anyway. That keeps the add-ons working but leaves Apple `container` unable to run two projects.

## Manual Testing Instructions

```bash
ddev utility download-ddev --pr 9045
export PATH="$HOME/tmp/ddev-download-ddev/pr-9045:$PATH"
mkdir -p ~/tmp/f1 && cd ~/tmp/f1
ddev config --project-type=php
ddev start
docker inspect -f '{{range .Mounts}}{{.Name}} {{end}}' ddev-f1-web ddev-f1-db
# Expect no ddev-global-cache
ddev exec 'openssl verify -CAfile $CAROOT/rootCA.pem /etc/ssl/certs/master.crt'
# Expect "OK": web signed its certificate with the host's CA
ddev exec curl -sI https://f1.ddev.site | head -1
# Expect HTTP 200 with no certificate error
ddev restart && ddev exec curl -sI https://f1.ddev.site | head -1
```

## Automated Testing Overview

- `TestCARootArchive` checks the archive's order, ownership, and modes.
- `TestWebCAROOTCopied` starts a project and checks several things: web and db don't mount `ddev-global-cache`, web's CA matches the host's, the container user owns the key with mode 600, and `openssl verify` accepts `master.crt`.
- `TestProjectCacheVolumes` no longer checks that db's `ddev-global-cache` mount is read-only.

## Release/Deployment Notes

Add-on maintainers whose web-side scripts write to `/mnt/ddev-global-cache` need to add the mount shown above.

🤖 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
stasadev added a commit that referenced this pull request Nov 20, 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

dependencies Pull requests that update a dependency file enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants