fix: dir-mount a dedicated Claude config dir for the CLI backend#90
Merged
Conversation
The CLI backend mounted the host's `~/.claude/.credentials.json` as a single file. The Claude CLI refreshes its short-lived OAuth token via atomic rename (new inode), but a single-file bind mount is pinned to the inode resolved at container start — so the container keeps reading the stale, expired token and fails with "authentication expired" until the stack is restarted. Switch to mounting a dedicated config *directory* (`~/clayde-claude`), which resolves the path live and picks up refreshes with no restart. The README previously claimed host refreshes were "immediately reflected" — they were not; this corrects the docs and the compose mount. Using a dedicated login (separate `CLAUDE_CONFIG_DIR`) also isolates the container from the host's personal `~/.claude` state and gives it its own OAuth refresh-token lineage, so container refreshes can't invalidate the host login (refresh tokens are single-use). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
CLAYDE_CLAUDE_BACKEND=cli, the container fails intermittently with "claude authentication expired". Restarting the Docker Compose stack temporarily fixes it.Root cause:
docker-compose.ymlbind-mounted the host's~/.claude/.credentials.jsonas a single file. The Claude CLI refreshes its short-lived OAuth token by writing a temp file and atomicallyrename()-ing it into place — which changes the file's inode. A single-file bind mount is pinned to the inode resolved at container start, so the container keeps reading the stale, expired token forever. A restart re-resolves the mount → works again, until the next refresh.The README also documented this as working — "Token refreshes... are immediately reflected" — which is the opposite of the actual behavior.
Fix
~/clayde-claude→/home/clayde/.claude) instead of the single credentials file. A directory mount resolves the path live, so refresh atomic-renames are picked up — no restart needed.CLAUDE_CONFIG_DIR=~/clayde-claude claude login) rather than the host's personal~/.claude. This isolates the container from the host's sessions/projects/history, and gives it its own OAuth refresh-token lineage so its refreshes can't invalidate the host login (refresh tokens are single-use).Changed
docker-compose.yml— file mount → dedicated dir mount (with rationale comment)README.md— CLI backend setup steps + corrected mount explanationCLAUDE.md— CLI backend requirements lineVerified
Applied the same change to a live deployment, recreated the stack, confirmed the container reads the token via the directory mount, and the Pebble webhook works. Host login remained intact (separate lineage).
🤖 Generated with Claude Code