Repository navigation
Description
Summary
CLI logins (gh, cf) only survive a rebuild if a repo's own devcontainer.json declares a volume for them, and most repos made from this template don't. cf persistence landed in c560581 (2026-10-08) as two more lines to copy into every repo. Most repos never got them, so cf auth login is lost on every rebuild there.
Each project also logs in separately (one volume per project, and per variant: #209). Every gh auth login mints another OAuth token, and GitHub's cap of 10 per user and app revokes the least recently used one. So logging in to one project can sign another out.
How far repos have drifted
Of 10 downstream repos checked on 2026-10-20, only 2 have the cf volume, and 5 lack the older gh volume too.
Why a copy per repo can't be fixed from here
- Image metadata or a Feature could carry
mountscentrally. The spec putsmountsin thedevcontainer.metadatalabel, and Features supportmountswith${devcontainerId}(the docker-in-docker Feature does this). - But under Compose (this template),
devcontainers/cliturns every mount into a Compose service volume. It writes onlyexternal: trueinto the top-levelvolumes:entry, nevername:(src/spec-node/dockerCompose.ts,convertMountToVolumeTopLevelElement). So any mount fromdevcontainer.json, a label or a Feature gets Compose's project prefix ([BUG] default and sandbox variants don't share volumes (Compose project-name prefix) #209). An external volume has to exist first, which needs a host-sideinitializeCommandin each repo. - A fixed top-level
name:indocker-compose.ymlis the one way to get an unprefixed volume that Compose creates on first use. It works: a Bun package store shared across projects already uses it downstream.
Proposal
-
Declare the login volumes in
docker-compose.ymlwith fixed names, one per machine:services: devcontainer: volumes: - gh-config:/home/node/.config/gh - cloudflare-config:/home/node/.config/cloudflare volumes: gh-config: name: devcontainers-gh-config cloudflare-config: name: devcontainers-cloudflare-config
Then remove the two
mountsentries from bothdevcontainer.jsonfiles.chownstays as it is (the Dockerfile already pre-creates both directories). The sandbox variant gets the same block, so it shares the login. That resolves the login part of [BUG] default and sandbox variants don't share volumes (Compose project-name prefix) #209.- Benefit: you log in once per machine. There is one
ghtoken, so projects stop revoking each other's. - Cost: every devcontainer on the machine holds the same
ghandcfcredentials. That is already true of the account; per-project volumes isolate only the token, not what it can reach.
- Benefit: you log in once per machine. There is one
-
Keep repos in step: add the block to the sync manifest of the
devcontainer-upstream-syncskill, so an audit catches a repo without it. That is the per-repo step that remains until devcontainers/cli passesname:through. -
Optional, upstream of this repo: ask devcontainers/cli to pass a mount's
name(or a "no project prefix" flag) through to Compose. Mounts could then move into the image'sdevcontainer.metadatalabel, and repos would need no edit at all.
Open questions
- Should the sandbox variant share the
cflogin? A sandbox that runs untrusted code with a deploy-capable Cloudflare login can deploy.ghsharing is wanted ([BUG] default and sandbox variants don't share volumes (Compose project-name prefix) #209). Forcf, a read-only login (cf auth login --scopes …) may be the safer default for every variant. - Migration: the old per-project volumes become orphans; you sign in once more.
Related
- gh config volume #114 (gh config volume, added per repo)
- [BUG] default and sandbox variants don't share volumes (Compose project-name prefix) #209 (default and sandbox variants don't share volumes)
- claude-code template: plugins added to init-plugins.sh never reach existing containers unless the script is run by hand #171 (same per-repo drift, for plugins)
- c560581 (cf volume added to the template)
Activity