Repository navigation
fix: copy global commands into each container instead of the shared volume, fixes #5806, for #8895 - #8956
Conversation
Effect on
|
main |
This PR | |
|---|---|---|
Docker, start after ~/.ddev/commands changed |
303 ms volume copy, blocks the start | 42 ms per-container copy, in the background, 0 ms wait |
Podman, start after ~/.ddev/commands changed |
907 ms volume copy, blocks the start | 25–112 ms per-container copy, in the background, 0 ms wait |
| Start with commands unchanged | Copy skipped by the hash check | Same background copy, 0 ms wait |
mainpaid the volume copy whenever the commands changed, which includes every start after a DDEV upgrade, because the upgrade rewrites the bundled commands. This PR removes that cost.- The copy now runs on every start, but it overlaps the wait for the containers to become ready. An A/B test on Podman with the same binary, copy on vs. off over 8 pairs, gave 18.13 s average start time both ways, and readiness of 3.50 s vs. 3.51 s.
- Containers don't stall during the copy. A ticker inside the containers showed a longest gap of 20 ms on both engines.
- The first start after upgrading removes the old
/mnt/ddev-global-cache/global-commands. That runs in the existingstart-chowncontainer, so it starts no extra container, and later starts have fewer files tochown -R.
macOS, Windows and WSL2 weren't measured. The copy is one tar upload per container through the Docker API there too, so the same pattern is expected. Once CI finishes, it's worth comparing the overall test durations with recent main runs, because the CI jobs cover those platforms and start many projects.
🤖 Developed with assistance from Claude Code
|
Download this PR's build for your OS and architecture with: ddev utility download-ddev --pr 8956Or download the artifact for your OS and architecture directly:
See Testing a PR. |
|
Pushed updated container image(s) for this PR:
|
3cf0266 to
063b3cc
Compare
|
Rebased |
rfay
left a comment
There was a problem hiding this comment.
I had Claude test this on macOS with rootless podman. The main fix works: after switching DDEV_XDG_CONFIG_HOME and back, each start leaves the container with the right directory's commands, hello-global works, xdebug resolves to /usr/local/lib/ddev/global-commands/web/xdebug, the old volume copy and .global-commands-hash are gone, and ddev utility fix-commands reports what it copied, inside and outside a project.
Here is what was found.
Bugs
-
A recreated service loses its global commands (reproduced).
recreateServices(pkg/ddevapp/ddevapp.go) creates new containers but never callsPopulateGlobalCustomCommandFiles. Afterddev restart -s db, the db container has no/usr/local/lib/ddev/global-commands/db, andddev mysqlfails:Error: crun: executable file `/usr/local/lib/ddev/global-commands/db/mysql` not found: No such file or directoryddev utility rebuild -s dbgoes through the same code path. With the shared volume these commands survived a recreate. -
Deleted or renamed commands stay in the container (reproduced). Extracting the tar only adds or overwrites files. The old
CopyIntoVolume(..., destroyExisting=true)cleared the directory first. After I deleted~/.ddev/commands/web/hello-global, it was still in the container afterddev utility fix-commandsand afterddev starton the running project. Onlyddev restartremoved it. In web the stale file also stays on PATH through the00-path-setup.bashrcfallback, so a removed wrapper such as a customyarnkeeps shadowing the real binary. Removing the target directory before extracting would fix this. -
ddev start --profiles=xon a running project.startProfileServicesbrings up the new services without going throughstart(), so they don't get global commands either. For example, a command in~/.ddev/commands/solr/fails until a full restart. The fix is probably the same as for 1: copy after composeUp in both places. -
A symlinked service directory is skipped without any message. If
~/.ddev/commands/webis a symlink (to a dotfiles repo, for example),WalkDirdoesn't descend into it, andReadFilefails because the target is a directory, so that service's commands are left out of the archive. The host side (cmd/ddev/cmd/commands.go) follows the symlink and registers the commands anyway, so they show up inddev helpbut fail in the container, and nothing is logged. A symlinked root and symlinked files are handled. Symlinked subdirectories aren't.
Lower severity
-
Hidden directories count as services. If
~/.ddev/commandsis a git checkout,.gitis treated as a service (the container lookup fails quietly), and the whole tree,.gitobjects included, is read into memory and copied into web and db on every start. Skipping entries that start with a dot would avoid this. -
Files in the container are dated 1969. The tar headers don't set
ModTime. Worth being reasonable.
Style
-
The comment at
pkg/ddevapp/ddevapp.go:1814, "Global commands no longer live in the volume", describes the change rather than the current design..claude/rules/comments.mdasks for the latter. -
cmd/ddev/cmd/commands_test.go:75is a rewritten line that still usesassert.NoError. We normally preferrequire.
063b3cc to
49c8783
Compare
|
Rebased with minor changes, new versionconstants, one DDEV_DEBUG becomes DDEV_VERBOSE in keeping wtih recent updates. |
|
Sorry, shouldn't have done that with a draft. I just saw it needing rebase and am looking forward to it landing. We're going to get apple containers in there yet. |
|
Pushed updated container image(s) for this PR:
|
…che read-only in db, for ddev#8895 ddev#8956 copies global commands into each container, including custom services, so this PR no longer moves them. Web and db run global commands from ddev-global-cache again, as on main, and db mounts ddev-global-cache read-only so it can reach them. Whichever of the two PRs lands second removes db's mount. 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]>
…emoved ones Addresses the review on #8956: - `ddev restart -s`, `ddev utility rebuild -s` and `ddev start --profiles` on a running project copy global commands into the new containers. - Each copy first removes the old directory in the container, so a deleted or renamed command doesn't stay on PATH. - Symlinked service directories are followed, with a guard against symlink loops. - Hidden directories such as `.git` are left out. - Files keep their host modification time. - The custom service docs no longer ask for a `container_name`, which DDEV already sets. `TestPopulateGlobalCustomCommandFiles` now covers the code changes except `--profiles`, which was checked by hand with a busybox profile service. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…emoved ones Addresses the review on #8956: - `ddev restart -s`, `ddev utility rebuild -s` and `ddev start --profiles` on a running project copy global commands into the new containers. - Each copy first removes the old directory in the container, so a deleted or renamed command doesn't stay on PATH. - Symlinked service directories are followed, with a guard against symlink loops. - Hidden directories such as `.git` are left out. - Files keep their host modification time. - The custom service docs no longer ask for a `container_name`, which DDEV already sets. `TestPopulateGlobalCustomCommandFiles` now covers the code changes except `--profiles`, which was checked by hand with a busybox profile service. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2a50cc7 to
c57583b
Compare
rfay
left a comment
There was a problem hiding this comment.
This seems great, but I haven't spent enough time with it myself yet. I added one commit to fix simple thing on test, and then rebased it, and the rebase of course showed the confusion going on about ddev-global-cache right now, so it may still need some help. So I fiddled with it more than intended, but wanted to save you the retag/rebase headache as other things went in, and am excited to see how far this may get us with Apple container. Claude is quite happy with it. I know because I used /stas-review :)
|
Pushed updated container image(s) for this PR:
|
…olume `ddev start` now copies `~/.ddev/commands` into each container's own filesystem instead of the shared `ddev-global-cache` volume, so global web and db commands can no longer go missing or stale. - For #8895 - For #5806 The volume copy was skipped while a hash in the global config directory matched, but every global config directory (`DDEV_XDG_CONFIG_HOME`) shares one volume, so a project could end up with another directory's commands and fail with "No such file or directory". After `compose up`, DDEV uploads one tar of `~/.ddev/commands`, without `host/`, to `/usr/local/lib/ddev/global-commands` in every running container whose service has a directory there, custom services included. It runs while the containers become ready, so there is no cache to keep in sync and no added start time, and a start after a commands change no longer pays for the volume copy (0.3 s on Docker, 1 s on Podman). Symlinked command files are resolved, and every file is made executable for Windows hosts. ```bash ddev utility download-ddev --pr 8956 export PATH="$HOME/tmp/ddev-download-ddev/pr-8956:$PATH" printf '#!/usr/bin/env bash\necho hello from global command\n' > ~/.ddev/commands/web/hello-global mkdir -p ~/tmp/globalcmd-test && cd ~/tmp/globalcmd-test ddev config --project-type=php && ddev start -y DDEV_XDG_CONFIG_HOME=$HOME/tmp/globalcmd-xdg ddev restart ddev restart ddev hello-global # prints the greeting; fails on main ddev exec 'type -p xdebug' # /usr/local/lib/ddev/global-commands/web/xdebug ddev utility fix-commands # says what was copied where ``` Clean up with `ddev delete -Oy globalcmd-test`, `rm -r ~/tmp/globalcmd-test ~/tmp/globalcmd-xdg ~/.ddev/commands/web/hello-global`. Docs: https://ddev--8956.org.readthedocs.build/en/8956/users/extend/custom-commands/#global-commands `TestPopulateGlobalCustomCommandFiles` checks the web and db copies, a symlinked command and that `host/` is left out; the existing custom command tests use the new path. Global container commands moved from `/mnt/ddev-global-cache/global-commands` to `/usr/local/lib/ddev/global-commands`, and the first `ddev start` after upgrading removes the old copy. Custom services no longer need the `ddev-global-cache` mount to run them. `ddev utility fix-commands` outside a project refreshes every running project. 🤖 Developed with assistance from [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…emoved ones Addresses the review on #8956: - `ddev restart -s`, `ddev utility rebuild -s` and `ddev start --profiles` on a running project copy global commands into the new containers. - Each copy first removes the old directory in the container, so a deleted or renamed command doesn't stay on PATH. - Symlinked service directories are followed, with a guard against symlink loops. - Hidden directories such as `.git` are left out. - Files keep their host modification time. - The custom service docs no longer ask for a `container_name`, which DDEV already sets. `TestPopulateGlobalCustomCommandFiles` now covers the code changes except `--profiles`, which was checked by hand with a busybox profile service. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
archive/tar rounds a header's ModTime to the nearest second when no Format is set, so TestPopulateGlobalCustomCommandFiles failed whenever the host file's sub-second part was 0.5s or more, as on the macOS and Windows mutagen Buildkite runs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Global commands no longer live in the volume, and package caches and history moved to the project cache volumes, so custom services don't need the mount to run custom commands. Co-Authored-By: Claude Opus 5.5 <[email protected]>
5a714c6 to
737a1bb
Compare
There was a problem hiding this comment.
Thanks for the rebase. One conflict went the wrong way: start() got back chown -R uid:gid /mnt/ddev-global-cache, which #9024 replaced with chmod 1777 so the shared volume is never chowned. Nothing tests it, so CI stayed green.
Claude Code fixed it in 590fb4533, so the chown lines match main again. make staticrequired passes. The rest of your changes look right: the mtime rounding fix matches what archive/tar does, and the architecture page now lists only mkcert.
Update: the one-time rm -rf /mnt/ddev-global-cache/global-commands broke older DDEV builds that use another global config directory. Their .global-commands-hash still matches, so they skip the volume copy, and ddev xdebug status failed with No such file or directory even after ddev restart. fce1eee drops the rm -rf, so the old copy stays in the volume. FixObsolete still deletes the hash file, so a downgrade in the same directory copies the commands again. On rootless Docker 29.9.2, Claude Code checked that an upgrade deletes the hash file and that a main build project in another config directory still runs ddev xdebug status. The release note in the PR body now says the old copy stays.
🤖 Developed with assistance from Claude Code
The first `ddev start` after upgrading removed `/mnt/ddev-global-cache/global-commands` from the shared volume. An older DDEV that uses another global config directory skips its volume copy while its own `.global-commands-hash` matches, so its projects lost every global container command, and `ddev restart` didn't bring them back: ``` $ ddev xdebug status bash: line 1: /mnt/ddev-global-cache/global-commands/web/xdebug: No such file or directory ``` The old copy now stays in the volume. It costs only disk space, because the volume is no longer chowned recursively. `FixObsolete` still deletes `.global-commands-hash`, so a downgrade in the same directory copies the commands again. Claude Code started a project with the `main` build and then this build in one config directory on Docker 29.9.2 (rootless). The hash was gone, and the `main` build's project in another config directory still ran `ddev xdebug status`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay
left a comment
There was a problem hiding this comment.
Looks great. Claude likes it. I deleted all the relevant volumes and then started a project and poked around for things being in the right place; Everything is good.
…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
…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
…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
…#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]>
Short Summary (TL;DR)
ddev startnow copies~/.ddev/commandsinto each container's own filesystem instead of the sharedddev-global-cachevolume, so global web and db commands can no longer go missing or stale.The Issue
The volume copy was skipped while a hash in the global config directory matched, but every global config directory (
DDEV_XDG_CONFIG_HOME) shares one volume, so a project could end up with another directory's commands and fail with "No such file or directory".How This PR Solves The Issue
After
compose up, DDEV uploads one tar of~/.ddev/commands, withouthost/, to/usr/local/lib/ddev/global-commandsin every running container whose service has a directory there, custom services included. It runs while the containers become ready, so there is no cache to keep in sync, and a start after a commands change no longer pays for the volume copy (timings are in the first comment).ddev restart -s,ddev utility rebuild -sandddev start --profilescopy the commands into the containers they create. Each copy first removes the old directory in the container, so removed commands disappear. Symlinked files and directories are followed, hidden directories such as.gitare left out, and every file is made executable for Windows hosts.Manual Testing Instructions
Clean up with
ddev delete -Oy globalcmd-test,rm -r ~/tmp/globalcmd-test ~/tmp/globalcmd-xdg ~/.ddev/commands/web/hello-global. Docs: https://ddev--8956.org.readthedocs.build/en/8956/users/extend/custom-commands/#global-commandsAutomated Testing Overview
TestPopulateGlobalCustomCommandFileschecks the web and db copies, symlinked files and directories, a symlink loop, thathost/and.git/are left out, file times, removal of a deleted command, and the copy afterRecreateServices. The existing custom command tests use the new path.Release/Deployment Notes
Global container commands moved from
/mnt/ddev-global-cache/global-commandsto/usr/local/lib/ddev/global-commands. The old copy stays in the volume, because an older DDEV that uses another global config directory still runs commands from it. Custom services no longer need theddev-global-cachemount to run them.ddev utility fix-commandsoutside a project refreshes every running project.🤖 Developed with assistance from Claude Code