Repository navigation
feat: copy the mkcert root CA into web at /usr/local/lib/ddev/mkcert instead of mounting ddev-global-cache, for #8895 - #9045
Conversation
|
Pushed updated container image(s) for this PR:
|
|
Download this PR's build for your OS and architecture with: ddev utility download-ddev --pr 9045Or download the artifact for your OS and architecture directly:
See Testing a PR. |
01e24a1 to
289f9c1
Compare
|
Pushed updated container image(s) for this PR:
|
stasadev
left a comment
There was a problem hiding this comment.
One problem left: the mkcert symlink ends up in an empty ddev-global-cache, details inline.
The rest works. Claude Code ran ddev start, ddev restart --service web and ddev restart on Docker 29.9.2 on Linux, with and without the add-on mount on web. openssl verify on master.crt, curl to the project URL and to https://web, and Node through NODE_EXTRA_CA_CERTS all pass. With the mount, the volume's own mkcert directory is no longer touched.
🤖 Reviewed with assistance from Claude Code
| ln -sf /run/php/php-fpm.sock /run/php-fpm.sock && \ | ||
| chmod -R ugo+rw /mnt/ddev-global-cache/ /mnt/ddev-project-cache/ | ||
| chmod -R ugo+rw /mnt/ddev-global-cache/ ${CAROOT} /mnt/ddev-project-cache/ && \ | ||
| ln -s ${CAROOT} /mnt/ddev-global-cache/mkcert |
There was a problem hiding this comment.
When ddev-global-cache is empty and a project mounts it on web, Docker copies this symlink into the volume. That's the state on a fresh install: the prep container only runs chmod on the volume, and the CA goes in after composeUp. After that, CopyIntoVolume can't create mkcert in the volume, so add-on services that read the CA from there (selenium, the example in custom-compose-files.md) get nothing in any project until the volume is deleted.
The same steps on a scratch volume:
$ docker run --rm -v gc:/mnt/ddev-global-cache ddev/ddev-utilities chmod 1777 /mnt/ddev-global-cache
$ docker create -v gc:/mnt/ddev-global-cache ddev/ddev-webserver:e2788dfc8d
$ docker run --rm -v gc:/mnt/v ddev/ddev-utilities sh -c 'ls -l /mnt/v; mkdir -p /mnt/v/mkcert'
lrwxrwxrwx 1 root root 26 Nov 2 15:24 mkcert -> /usr/local/lib/ddev/mkcert
mkdir: can't create directory '/mnt/v/mkcert': No such file or directory
With a089c734b0 the volume gets an empty mkcert directory and mkdir works. Maybe have the prep container create it, so the volume is never empty when web is created?
chownCmd := fmt.Sprintf("chmod 1777 /mnt/ddev-global-cache; mkdir -p /mnt/ddev-global-cache/mkcert; chown -R %s:%s", uid, gid)| if err != nil { | ||
| return nil, err | ||
| } | ||
| if err := tw.WriteHeader(&tar.Header{Typeflag: tar.TypeReg, Name: path.Join(root, f.name), Mode: f.mode, Size: int64(len(content)), Uid: uid, Gid: gid}); err != nil { |
There was a problem hiding this comment.
Small thing: without ModTime the CA files in web are dated 1 January 1970. ModTime: time.Now() would fix it.
e4b41cb to
18b0b81
Compare
…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
…#8895 composeUp now creates the containers, copies the root CA into web, and then starts them, so web's start.sh finds the CA in place and mkcert signs with it. This replaces the DDEV_WAIT_FOR_CAROOT wait loop in start.sh and the .ddev-copied marker, and reverts the webserver image tag to the one on main, since the image no longer changes. Because every composeUp caller copies, `ddev restart web`, which recreates web without a full start, now gets the CA too. TestWebCAROOTCopied checks that case. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Web no longer mounts ddev-global-cache, so its copy of the mkcert root CA now lives at /usr/local/lib/ddev/mkcert, next to the global commands, instead of under a path that looks like the volume. When an add-on mounts ddev-global-cache on web again, that mount no longer covers the CA, and the copy no longer writes the key into the shared volume. /mnt/ddev-global-cache/mkcert in the image is a symlink to the new location, so scripts that read the old path keep working. NODE_EXTRA_CA_CERTS and the docs use the new path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… for ddev#8895 The RUN steps that create web's CAROOT and its symlink now expand ${CAROOT}, which ddev-webserver-base sets, instead of repeating the path. The FROM scratch stages still set CAROOT literally, since they start with an empty environment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…starts, for ddev#8895 The webserver bats tests mounted a volume with the CA at /mnt/ddev-global-cache, which now hides the image's symlink, leaving CAROOT empty. start.sh then created its own CA, and the host's curl rejected the certificate. test.sh now creates each container, copies the host's CA into /usr/local/lib/ddev/mkcert, and then starts it, as DDEV does, so the test volume is no longer needed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he copied CA files, for ddev#8895 When ddev-global-cache was empty and web mounted it, Docker copied web's mkcert symlink into the volume, so the CA could no longer be copied there for add-on services. The prep container now creates the mkcert directory before web is created. The tar copied into web also had no ModTime, leaving the CA files dated 1 January 1970. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ddev#8895 Co-Authored-By: Claude Opus 5.5 <[email protected]>
de5d408 to
ef1def5
Compare
…ev#7372 Since ddev#9045 copies the mkcert root CA into web, neither web nor db mounts ddev-global-cache, so it no longer needs a host bind mount on apple container. Only short-lived helpers and add-ons mount the volume now. Removes UseBindGlobalCache(), GlobalCacheSource(), GlobalCacheMount(), DDEV_BIND_GLOBAL_CACHE, copyIntoGlobalCache and the BindGlobalCache and GlobalCacheMount template variables. ddevapp.go, config.go and app_compose_template.yaml now match upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd the CA copy gap, for ddev#7372 [skip ci] Co-Authored-By: Claude Opus 5.5 <[email protected]>
## 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]>
…ev#7372 Since ddev#9045 copies the mkcert root CA into web, neither web nor db mounts ddev-global-cache, so it no longer needs a host bind mount on apple container. Only short-lived helpers and add-ons mount the volume now. Removes UseBindGlobalCache(), GlobalCacheSource(), GlobalCacheMount(), DDEV_BIND_GLOBAL_CACHE, copyIntoGlobalCache and the BindGlobalCache and GlobalCacheMount template variables. ddevapp.go, config.go and app_compose_template.yaml now match upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd the CA copy gap, for ddev#7372 [skip ci] Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ev#7372 Since ddev#9045 copies the mkcert root CA into web, neither web nor db mounts ddev-global-cache, so it no longer needs a host bind mount on apple container. Only short-lived helpers and add-ons mount the volume now. Removes UseBindGlobalCache(), GlobalCacheSource(), GlobalCacheMount(), DDEV_BIND_GLOBAL_CACHE, copyIntoGlobalCache and the BindGlobalCache and GlobalCacheMount template variables. ddevapp.go, config.go and app_compose_template.yaml now match upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd the CA copy gap, for ddev#7372 [skip ci] Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ev#7372 Since ddev#9045 copies the mkcert root CA into web, neither web nor db mounts ddev-global-cache, so it no longer needs a host bind mount on apple container. Only short-lived helpers and add-ons mount the volume now. Removes UseBindGlobalCache(), GlobalCacheSource(), GlobalCacheMount(), DDEV_BIND_GLOBAL_CACHE, copyIntoGlobalCache and the BindGlobalCache and GlobalCacheMount template variables. ddevapp.go, config.go and app_compose_template.yaml now match upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd the CA copy gap, for ddev#7372 [skip ci] Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ev#7372 Since ddev#9045 copies the mkcert root CA into web, neither web nor db mounts ddev-global-cache, so it no longer needs a host bind mount on apple container. Only short-lived helpers and add-ons mount the volume now. Removes UseBindGlobalCache(), GlobalCacheSource(), GlobalCacheMount(), DDEV_BIND_GLOBAL_CACHE, copyIntoGlobalCache and the BindGlobalCache and GlobalCacheMount template variables. ddevapp.go, config.go and app_compose_template.yaml now match upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd the CA copy gap, for ddev#7372 [skip ci] Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ev#7372 Since ddev#9045 copies the mkcert root CA into web, neither web nor db mounts ddev-global-cache, so it no longer needs a host bind mount on apple container. Only short-lived helpers and add-ons mount the volume now. Removes UseBindGlobalCache(), GlobalCacheSource(), GlobalCacheMount(), DDEV_BIND_GLOBAL_CACHE, copyIntoGlobalCache and the BindGlobalCache and GlobalCacheMount template variables. ddevapp.go, config.go and app_compose_template.yaml now match upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd the CA copy gap, for ddev#7372 [skip ci] Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ev#7372 Since ddev#9045 copies the mkcert root CA into web, neither web nor db mounts ddev-global-cache, so it no longer needs a host bind mount on apple container. Only short-lived helpers and add-ons mount the volume now. Removes UseBindGlobalCache(), GlobalCacheSource(), GlobalCacheMount(), DDEV_BIND_GLOBAL_CACHE, copyIntoGlobalCache and the BindGlobalCache and GlobalCacheMount template variables. ddevapp.go, config.go and app_compose_template.yaml now match upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd the CA copy gap, for ddev#7372 [skip ci] Co-Authored-By: Claude Opus 5.5 <[email protected]>
…#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]>
…#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]>
…#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]>
Dependencies: none, and it merges cleanly with the others. Interacts with #9046: if #9046 merges first, this PR must delete the
"ddev-global-cache"entry fromknownSharedVolumes, or that test fails. Needs discussion: web no longer mountsddev-global-cache, which affects some add-ons. See below.One of seven PRs for #8895, which can be reviewed separately: #9040, #9041, #9042, #9043, #9044, #9045, #9046.
Short Summary (TL;DR)
DDEV now copies the host's mkcert root CA into the web container before it starts, at
/usr/local/lib/ddev/mkcert, and web and db no longer mountddev-global-cache. This removes the last volume DDEV's own containers share across projects. Add-ons that write to/mnt/ddev-global-cachefrom web are affected; see below.The Issue
Web mounted
ddev-global-cacheread-write in every project, and db mounted it read-only, mainly so web could read the mkcert CA at/mnt/ddev-global-cache/mkcert. Applecontainerallows one read-write attachment of a volume, so even two projects could not run at once there. Since #9024 and #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
composeUpnow runs compose's create and start as separate steps, andcopyCAROOTIntoWebruns between them. It copiesrootCA.pemandrootCA-key.peminto web in one tar, like fix: copy global commands into each container instead of the shared volume, fixes #5806, for #8895 #8956 does for global commands, owned by the container user. Web'sstart.shfinds the CA already there when it runsmkcert, so it needs no wait and no image-side flag. EverycomposeUpcaller gets the copy, includingddev restart --service web, which recreates web without a full start.CAROOTmoves to/usr/local/lib/ddev/mkcert, next to the global commands at/usr/local/lib/ddev/global-commands. When an add-on mountsddev-global-cacheon web again, that mount no longer covers the CA, and the copy doesn't write the key into the shared volume./mnt/ddev-global-cache/mkcertin the image is a symlink to the new location, so scripts that read the old path keep working.NODE_EXTRA_CA_CERTSand the docs use the new path.ddev-global-cache. The compose file still declares the volume, so add-on services keep mounting it. DDEV still fillsddev-global-cache/mkcertfor add-on images that readCAROOTfrom there.For discussion: add-ons that use the volume from web
Several add-ons write to
/mnt/ddev-global-cachefrom the web container without mounting it themselves:ddev-nvm(nvm_dir),ddev-pnpm(PNPM_HOME),ddev-platformshandddev-upsun(PLATFORM_CACHE_DIR). After this change their data lives in the container, so addev restartloses it. Nothing fails outright:ddev-nvmextracts its copy from the image again on each start. Each add-on can get the old behavior back with three lines in itsdocker-compose.*.yaml. The architecture docs now show them: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
containerunable to run two projects.Manual Testing Instructions
Automated Testing Overview
TestCARootArchivechecks the archive's paths, ownership, and modes.TestWebCAROOTCopiedstarts a project and checks several things: web and db don't mountddev-global-cache, web's CA matches the host's, both through$CAROOTand through the old path's symlink, the container user owns the key with mode 600, andopenssl verifyacceptsmaster.crt, both afterddev startand afterddev restart --service web.TestProjectCacheVolumesno longer checks that db'sddev-global-cachemount is read-only.Release/Deployment Notes
Add-on maintainers whose web-side scripts write to
/mnt/ddev-global-cacheneed to add the mount shown above. Web'sCAROOTis now/usr/local/lib/ddev/mkcert; the old path still works through a symlink.🤖 Developed with assistance from Claude Code
https://claude.ai/code/session_01UrTUMxNNNiQiA9QxsieVTQ
Generated by Claude Code