create persistent claude config storage using named volume#39
Open
IlmLV wants to merge 1 commit into
Open
Conversation
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.
Summary
/claude-config(scoped todevcontainerId) so Claude data survives container rebuilds without manual configurationCLAUDE_CONFIG_DIR=/claude-configin the container user's shell profiles, consolidating all Claude data — including the normally homeless~/.claude.json— into themounted volume
postCreateCommandfixes volume directory ownership after mounting (Docker creates volumes as root)Problem
Claude Code stores most data in
~/.claude/but writes its main config file to~/.claude.json(outside the directory). A volume mount at~/.claudealone does not persist~/.claude.json, requiring re-login on every rebuild.Symlinking
~/.claudeto a mounted volume does not work — the Claude CLI cannot read credentials through a symlinked directory.Solution
Using
CLAUDE_CONFIG_DIRredirects all Claude storage, including~/.claude.json, into a single directory that is directly volume-mounted. No symlinks involved. The named volume is scoped to the devcontainer instance, keeping credentials isolated from the host and other containers.Try it out
Test plan
echo $CLAUDE_CONFIG_DIRin terminal shows/claude-configls /claude-configshows.claude.jsonand credentials after first loginPR very similar to #34, difference is usage of ENV defined config directory.
Closes: #24
Related to: #34