Skip to navigation

Claude Code VS Code Dev Containers: Align CLAUDE_CONFIG_DIR

In short: Align the mounted config path, absolute CLAUDE_CONFIG_DIR and non-root container user before concluding that VS Code Dev Containers lost your login.

Published 16 min read
On this page

Direct answer

Align three values before treating a VS Code Dev Containers login prompt as lost authentication: the bind-mount target, the absolute CLAUDE_CONFIG_DIR value and the user whose home contains ~/.claude. Setting CLAUDE_CONFIG_DIR moves credential storage to that directory, but the path must also be accessible to the container user. Issue #26623 is an individual non-root report closed as a duplicate, not proof of a universal VS Code defect or a verified fix.

Why the IDE wrapper complicates a path problem

VS Code Dev Containers combines an editor, a development-container definition, a container user and one or more Claude Code launch surfaces. A path can be correct in the definition yet differ in the process that starts Claude Code. A mount can exist under one user’s home while another user’s session looks elsewhere.

That combination makes repeated login an attractive but weak diagnostic. Signing in again may populate a different directory, leave the original mismatch untouched and create more state to compare later. Record the effective user and paths before authenticating again.

The Docker config mount permissions guide covers ownership and write access. The persistent dev container authentication guide covers the official volume pattern. This article adds the VS Code-specific alignment check without claiming that every Dev Containers setup fails.

A second risk is evidence mixing. A terminal result from a local window can be compared with a container extension result from another project. Keep project identity, window context and container user attached to every observation. Otherwise a correct path in one context appears to fail in another.

Evidence boundaries

Community, F089: issue #26623 described a non-root VS Code Dev Containers setup with a bind-mounted ~/.claude directory and CLAUDE_CONFIG_DIR. The report names Claude Code 2.1.45 and closed as a duplicate. It does not establish a universal defect or current fix.

Official, F090: the environment-variable reference instructs users to write CLAUDE_CONFIG_DIR as an absolute path. Shorthand such as ~ or $HOME stays as typed.

Official, F091: the authentication reference says setting CLAUDE_CONFIG_DIR moves credential storage to that directory. A correct path still needs to be accessible to the container user.

Unknown: the duplicate target’s body and current state were not fetched in this research pass. No fix, root cause or version boundary is inferred from the duplicate status.

Evidence map comparing VS Code Dev Containers mount target, absolute config path and container user
Evidence map based on official path and credential-storage guidance plus community issue #26623. The duplicate report does not establish a universal defect or fix.

Identify the Dev Containers user

Start with the user context that launches Claude Code inside the development container. Record the user and effective home before comparing paths. A non-root user is part of the reported scenario in F089, not a claim that every container uses the same user.

The user’s home determines what ~/.claude means in that process. A mount target copied from another user’s home can look reasonable while sitting outside the active user’s configuration path.

Path element Value to compare Common mismatch
Runtime user User that starts Claude Code Definition checked under a different user
Effective home That user’s home directory Assuming every container uses /home/dev
Mount target Literal container path for the bind mount Mount attached under another home
CLAUDE_CONFIG_DIR Literal absolute path in the launch context Shorthand or a different absolute directory
Credential storage Directory selected by the config variable Client writes somewhere other than the mount
Access Read and update capability for the runtime user Correct path with insufficient permissions

The container user, HOME and workspace guide provides the broader alignment procedure. It deliberately avoids a universal UID or GID mapping because the supplied evidence does not establish one.

Locate the mounted ~/.claude directory

Find the bind mount in the development-container definition and compare its target with the intended user’s home. Keep the host source out of shared logs if it reveals private paths, but retain enough identity to distinguish two mounts.

The official development-container guidance recommends a volume at ~/.claude with CLAUDE_CONFIG_DIR for persistence. A bind mount can serve a similar path-alignment purpose, but access and host interaction still need verification.

Do not assume that seeing a .claude directory proves it is the active directory. Another mount, an unmounted empty directory or a different user’s home can produce the same listing. Compare the mount target with the config variable in the same process context.

The persistent authentication volume runbook covers rebuild verification. Use it after the three-way alignment passes.

Write an absolute CLAUDE_CONFIG_DIR

Write the literal absolute path to the mounted configuration directory. Under F090, shorthand such as ~ or $HOME stays as typed. A value that works as a visual abbreviation in documentation is not necessarily the value the client resolves.

For a hypothetical user whose home is /home/dev, the aligned values are:

Mount target: /home/dev/.claude
CLAUDE_CONFIG_DIR: /home/dev/.claude

Derived example: the equality establishes path alignment for this illustrative user. It does not establish that /home/dev is correct for another container, nor does it prove write access.

The absolute config-directory guide explains relocation across shells and IDEs. Its central rule applies here: record the value seen by the process that actually launches Claude Code.

Compare the environment target with the mount target

Treat this as a three-way comparison, not a single setting check. The mount target, the variable and the runtime user’s expected configuration directory must describe the same location.

Comparison Pass condition If it fails
Mount versus variable Both name the same absolute container path Correct the definition or environment value
Variable versus user home The path belongs to the intended user context Revisit user and home alignment
Mount versus access The runtime user can read and update the directory Repair intended access without bypassing permissions
Definition versus process The launched session sees the recorded value Inspect environment replacement and relaunch timing
Pre-rebuild versus post-rebuild Same mount, path and user remain effective Inspect mount lifecycle and definition changes

The settings environment and process replacement guide explains why a shell-inherited value and a settings-file value can differ. Relaunch when the feature reads the variable only at startup, then repeat the comparison.

A correct environment target does not prove credential precedence. If another source is active, the credential precedence runbook is the next reference. Do not rewrite the mount to solve an override.

Check credential-storage relocation

F091 says CLAUDE_CONFIG_DIR moves credential storage to that directory. Verify that the intended mounted directory is the one receiving the state. Avoid reading or exporting credential contents as proof.

A login completed before the path change may have written elsewhere. After correcting the absolute value and relaunching, complete the normal authentication flow if needed. Then rebuild or recreate the container and check whether the same state remains available.

Verification stage Evidence to retain Credential handling
Path aligned Mount target and variable match Do not display file contents
Relaunched New process sees the intended value Redact unrelated environment values
Authenticated Intended account completes normal sign-in Do not copy tokens into notes
Rebuilt Same volume and user remain effective Keep screenshots and logs redacted
Restarted Authentication and settings remain available Report pass or fail, not secret values

The credential storage path reference documents expected stores by operating system. It supports inspection without turning the credential file into a support artifact.

Workflow from Dev Containers user identification through mount, absolute config path, credential relocation and verification
Workflow derived from official path and authentication guidance. User context and mount access remain separate from the duplicate issue’s unverified outcome.

Separate CLI behavior from extension surfaces

Record which surface launched Claude Code. A container terminal and an editor-managed surface can be observed in different process contexts even when they appear beside the same project. Do not assume one result validates the other.

The VS Code extension and standalone CLI guide explains the two execution surfaces and their installation ownership. Use it to identify the component under test, not to infer that the extension panel and terminal always share one visible executable path.

Execution surface Configuration context to inspect Useful comparison
Dev Containers terminal User, home, environment and mount seen by that terminal Repeat the same path check after relaunch
Editor-managed Claude Code surface Launch context associated with the container project Record its result separately
Local VS Code window outside the container Local user and local config directory Do not compare it as if it were the container
Rebuilt container Same definition with recreated runtime state Check persistence after alignment

This article does not diagnose WebSocket failures or blank panels. Those are separate surfaces with separate evidence. The VS Code WebSocket regression guide is relevant only when the observed failure matches that connection problem.

Read the duplicate issue accurately

Issue #26623 names a non-root setup, a bind-mounted ~/.claude directory and CLAUDE_CONFIG_DIR. It also names Claude Code 2.1.45. Those details explain the reporter’s scenario. They do not establish that every non-root user or every 2.1.45 session fails.

The issue closed as a duplicate of #22066 and was not fixed individually. The underlying issue was linked but not fetched in this research pass. No maintainer response, fixed version or current state is asserted.

Issue fact Conclusion it supports Conclusion it does not support
Non-root setup was reported User context belongs in the checklist Non-root containers always lose login
Bind mount and config variable were present Paths still need comparison Presence proves correct alignment
Claude Code 2.1.45 was named The report has a specific version context A universal version boundary exists
Closed as a duplicate of #22066 The report was routed to another issue A verified fix exists
Underlying issue not fetched Outcome remains unknown The title reveals the root cause

The Docker mount permissions guide preserves the same evidence boundary. Community reports can guide what to inspect, but they cannot replace a local mount and user check.

Verify the aligned configuration

After aligning user, mount and absolute path, relaunch the relevant Claude Code session. Complete authentication if the normal flow requires it. Then rebuild or recreate the development container and repeat the check under the same user.

A pass means the same mounted directory remains accessible, the variable still names it and authentication plus intended settings remain available. A partial pass is still useful. Record which layer changed rather than collapsing the result into “works” or “broken.”

The settings validation and doctor guide can identify rejected entries after filesystem access is established. It does not prove that the mount belongs to the right user.

Tradeoff map comparing mount-path alignment, user accessibility and separate VS Code launch surfaces
Tradeoff map based on official path guidance and the bounded community report. Separate launch surfaces improve diagnosis but require separate evidence.

Worked example: find the third mismatch

Suppose a developer uses a non-root container user with home /home/dev. The bind mount targets /home/dev/.claude, but CLAUDE_CONFIG_DIR is set to /root/.claude. The mount and user context are clear, yet the variable points elsewhere.

Derived diagnostic classification: two of the three alignment values are known, and the config path does not match the mount. Correct the variable to /home/dev/.claude, relaunch and repeat access checks. Do not change mount ownership until path alignment passes.

Now suppose both paths match, but the container user cannot update the directory. Derived diagnostic classification: path alignment passes and access fails. Use the Docker permission checklist rather than another login or a new variable value.

A third outcome has matching paths and writable access, but authentication still disappears after rebuild. Unknown: the supplied evidence does not identify the cause. Compare mount lifecycle, credential source and the actual rebuild definition. The duplicate issue does not fill that gap.

Derived arithmetic: this example compares three independent values: mount target, config path and runtime user. 3 values produce a checklist, not a success score. A failure in any one prevents a clean alignment conclusion.

Three-way alignment matrix

Runtime user Mount target CLAUDE_CONFIG_DIR Classification Next action
Intended user Intended path Same absolute path Paths aligned Check access and rebuild behavior
Intended user Intended path Different absolute path Config-path mismatch Correct the literal value and relaunch
Intended user Another user’s path Same as mount User-home mismatch Revisit user and home alignment
Different runtime user Intended path Same absolute path Access context differs Inspect ownership as the actual user
Unrecorded Present Absolute Evidence incomplete Record all three before changing settings
Intended user Same absolute path Same path, read-only Access failure Repair intended write access

The five-scope settings precedence guide applies when settings differ after authentication persists. Keep settings resolution separate from credential relocation.

Build a reproducible alignment report

A useful report starts with the project and launch surface, then lists the three alignment values without credential contents. Include the runtime user, effective home, mount target and literal CLAUDE_CONFIG_DIR value. Add the read and write result for that user so a correct path is not mistaken for complete access.

Separate observations made before relaunch from those made afterward. A startup-sensitive variable can leave an older process on the previous value, so the process context matters as much as the edited definition. When the container is rebuilt, repeat the same fields rather than relying on the earlier session’s result.

For an editor-managed surface, document the result independently from the Dev Containers terminal. If one succeeds and the other asks for authentication, preserve both outcomes and their launch contexts. That difference is evidence to investigate, not a reason to declare the whole integration broken.

Issue #26623 can be cited as a similar reported scenario, provided the report also says it closed as a duplicate and names no verified fix. The underlying #22066 outcome remains unknown in this packet. Avoid attaching a fix version or root cause that the evidence does not contain.

The proof-of-work verification guide supplies a structure for the final packet. Redact secrets using the secret handling and transcript guide. Another developer should then be able to repeat the user, path and access checks without requesting the credential file itself.

Practical alignment checklist

  1. Record the project and VS Code window under test.
  2. Identify the user that launches Claude Code in the container.
  3. Record that user’s effective home.
  4. Locate the bind-mount target in the development-container definition.
  5. Write CLAUDE_CONFIG_DIR as the literal absolute mount target.
  6. Compare the value in the actual launch context.
  7. Verify read and write access for the runtime user.
  8. Relaunch after a startup-sensitive change.
  9. Complete normal authentication if required.
  10. Rebuild and verify the same user, mount and path.

The proof-of-work verification guide helps structure the result. The secret handling and transcript guide explains what to redact. Neither requires credential values to prove alignment.

Control checklist covering Dev Containers user, bind mount, absolute CLAUDE_CONFIG_DIR, access and rebuild verification
Control checklist assembled from official path guidance and issue #26623’s bounded scenario. Separate surfaces should not share an assumed result.

Concrete win, loss and implication

Win: a developer can distinguish a mount-target mismatch from a config-path mismatch and a user-access failure before repeating authentication. The three values turn an ambiguous login prompt into a specific correction.

Loss: a correct path can still fail when the runtime user cannot update the directory. Separate VS Code launch surfaces can also produce different observations, so one successful terminal check does not validate every surface.

Implication: record user, mount target and absolute config path together in the Dev Containers setup notes. Treat issue #26623 as a prompt to inspect those values, not as proof that VS Code needs a universal fix.

Data gap and future update

Issue #26623 was closed as a duplicate of #22066, but the underlying body and current state were not fetched. There is no verified fix or universal defect in the supplied evidence. The report’s 2.1.45 context must not become a general compatibility claim.

Recheck the underlying issue and current official documentation before adding a fixed version or broad workaround. A future update should also distinguish any officially documented VS Code-specific behavior from the general container path rules.

Verdict requiring matching mount target, absolute config path and accessible non-root container user
Verdict derived from official path and credential-storage guidance. The duplicate issue supplies a scenario to inspect, not a verified fix.

One AI option for OpenAI-format agents

One AI supports OpenAI-format agents with one key for https://api.oneaiapikey.com/v1 and 46 live free IDs listed at the free model catalogue. That offer is separate from Claude Code, uses a different request format and does not make the free IDs valid Claude Code credentials.

For a genuinely separate connection failure, the VS Code WebSocket regression guide covers its own evidence. The WSL IDE environment-boundary guide applies when Windows and Linux launch contexts are involved. The settings-file secret exposure guide remains relevant when collecting configuration evidence. More runbooks are available in the Claude Code blog, with official entry points in the documentation hub.

FAQ

What three values must align?

The bind-mount target, the absolute CLAUDE_CONFIG_DIR value and the runtime user whose home contains the intended ~/.claude directory. Access for that user is a separate required check.

Does issue #26623 prove VS Code Dev Containers lost authentication universally?

No. It is an individual non-root report naming Claude Code 2.1.45 and closed as a duplicate of #22066. It was not fixed individually, and the underlying issue was not fetched in this research pass.

Can CLAUDE_CONFIG_DIR use ~ or $HOME?

Official guidance says to use an absolute path and notes that shorthand stays as typed. Write the literal container path to the mounted directory.

Why record terminal and extension results separately?

They can be launched in different process contexts. One successful surface does not prove the other saw the same user, environment or mount. Keep each observation attached to its launch surface.

More Claude Code troubleshooting

Sources

More in Blog

Try it

One API key for GPT, Grok, DeepSeek, Kimi, GLM, MiniMax, Qwen, Step, Beam, Nemotron, ERNIE, Hunyuan, Gemma, Laguna, LFM, LongCat, Llama, Solar, Jais, Mistral, K2 and Roleplay.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Credit packs start at $10, and every model has a published per-token rate.

New accounts$10 credit on sign-up
  • 100requests
    per day
  • 3Mtokens
    per day
  • 47free
    models
  • $0per
    token
  • No card
  • No end date
Claim $10 credit →