Integrated Claude/Codex in Dev Container - #136
srinath-iyer wants to merge 5 commits into
Conversation
|
Note: The linter fails because of new rules added in July 2026 to Ruff. These are fixed in #130 but are not here as it's improper to include here. |
There was a problem hiding this comment.
🟡 Changes recommended
Authentication initialization and path handling issues remain, along with unnecessary privileged container access.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds Claude Code and Codex CLI support to the VS Code Dev Container.
Changes:
- Installs both CLIs in the Docker image.
- Adds host authentication/configuration mounts.
- Documents setup and platform-specific authentication.
File summaries
| File | Changes |
|---|---|
SETUP.md |
Documents CLI usage and authentication behavior. |
docker/Dockerfile |
Installs Claude Code and Codex. |
docker-build.sh |
Creates host CLI configuration paths. |
.devcontainer/devcontainer.json |
Adds authentication mounts and container settings. |
Review details
Suppressed comments (4)
.devcontainer/devcontainer.json:11
initializeCommandinvokesdocker-build.sh skip-wsl, and that script exits at its WSL check before reaching the newmkdir/touchcommands. A first-time WSL Dev Container therefore still has missing auth paths (and Docker may create.claude.jsonas a directory), contrary to this comment and the documented auto-mount behavior. Move path creation before the skip or create the paths in a WSL-safe initialization step.
// docker-build.sh creates these paths on the host first if they don't already exist.
.devcontainer/devcontainer.json:15
- This source expression concatenates
HOMEandUSERPROFILEinstead of selecting one. On Windows/WSL environments where both variables are present, it expands to an invalid path such as/home/userC:\Users\user/.claude, so the bind mounts do not expose the host credentials. Use a single normalized host-home variable or separate OS-specific mount configuration.
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.claude,target=/home/ubuntu/.claude,type=bind",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.claude.json,target=/home/ubuntu/.claude.json,type=bind",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.codex,target=/home/ubuntu/.codex,type=bind"
SETUP.md:196
- The new setup note contains the typo
fro; please correct it tofor.
If you're using VS Code Dev Containers and already have Claude Code and/or the Codex CLI set up (logged in) on your host machine, the Dev Container automatically bind-mounts your host `~/.claude/`, `~/.claude.json`, and `~/.codex/` config/auth paths into the container. This means `claude`/`codex` are already logged in inside the container, and any changes (for example, updated settings or a new login) are shared between your host machine and the container. NOTE: This is only supported fro Linux/WSL. For MacOS, currently it is required to login every clean build.
docker-build.sh:58
- When
~/.claude.jsonis absent,touchcreates a zero-byte file. Since that file is then bind-mounted as Claude's JSON config, it is an existing but invalid configuration rather than an absent one and can make the CLI fail before login. Initialize it to{}only when absent, preserving any existing file.
touch ~/.claude.json
- Files reviewed: 4/4 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # Create Claude Code and Codex config/auth paths if they don't already exist | ||
| # The Dev Container bind-mounts these paths (see .devcontainer/devcontainer.json) so that a developer's existing | ||
| # Claude Code/Codex CLI login carries over into the container. Creating them here first ensures Docker mounts a | ||
| # file at ~/.claude.json (instead of creating an empty directory in its place, which is Docker's default | ||
| # behavior when bind-mounting a file path that doesn't exist yet) | ||
| mkdir -p ~/.claude | ||
| touch ~/.claude.json | ||
| mkdir -p ~/.codex |
| ### Claude Code and Codex CLIs | ||
| The Claude Code and Codex CLIs are installed in the Dev Container, so you can run `claude` or `codex` in any integrated terminal. | ||
|
|
||
| If you're using VS Code Dev Containers and already have Claude Code and/or the Codex CLI set up (logged in) on your host machine, the Dev Container automatically bind-mounts your host `~/.claude/`, `~/.claude.json`, and `~/.codex/` config/auth paths into the container. This means `claude`/`codex` are already logged in inside the container, and any changes (for example, updated settings or a new login) are shared between your host machine and the container. NOTE: This is only supported fro Linux/WSL. For MacOS, currently it is required to login every clean build. |
| ENV NVM_DIR=/home/ubuntu/.nvm | ||
| RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash \ | ||
| && . $NVM_DIR/nvm.sh \ | ||
| && nvm install --lts=Jod \ | ||
| && npm install -g @anthropic-ai/claude-code @openai/codex |
| # Create Claude Code and Codex config/auth paths if they don't already exist | ||
| # The Dev Container bind-mounts these paths (see .devcontainer/devcontainer.json) so that a developer's existing | ||
| # Claude Code/Codex CLI login carries over into the container. Creating them here first ensures Docker mounts a | ||
| # file at ~/.claude.json (instead of creating an empty directory in its place, which is Docker's default | ||
| # behavior when bind-mounting a file path that doesn't exist yet) |
| # Install the Claude Code and Codex CLIs | ||
| # These are installed here (rather than relying on a host install) so that they run natively regardless of the | ||
| # host machine's OS/architecture. The Dev Container bind-mounts each developer's host ~/.claude, ~/.claude.json, | ||
| # and ~/.codex config/auth paths (see .devcontainer/devcontainer.json), so these CLIs are already logged in if the | ||
| # developer has Claude Code and/or the Codex CLI set up on their host machine |
Alright bro |
d8ea4c4 to
e21b4f4
Compare
e21b4f4 to
0ef50be
Compare
0ef50be to
0d8806c
Compare



These changes allow you to run Claude/Codex in a VSCode Dev Container.
Roughly, it adds the install commands for Claude/Codex CLI to Dockerfile. Additionally, the devcontainer.json config pulls in the local auth info for codex and claude (for linux/wsl, as MacOS stores auth in Keychain).
Usage:
claudeorcodexin the terminal, and then login if on MacOS for every rebuild; if Linux/WSL, auto-login.Testing:
Tested on MacOS, and WSL, and Linux.
Future Work:
If MacOS re-login is a pain, we will find an alternative. For example, copying over the API key into
.env. But for now this is a minor inconvenience.