Claude Code Docker VSCode Setup Guide

Written by Michael Lip · Solo founder of Zovo · $400K+ on Upwork · 100% JSS Join 50+ builders · More at zovo.one

Running Claude Code inside Docker containers through VSCode Dev Containers gives you reproducible development environments with full AI assistance. This guide covers the complete setup from Dockerfile configuration to CLAUDE.md integration, so every team member gets the same Claude-powered experience regardless of their host OS.

The Problem

Developers using Claude Code on their local machines hit inconsistencies when switching between projects or collaborating with teammates on different operating systems. Docker Dev Containers solve environment drift, but getting Claude Code to work properly inside them requires specific configuration for authentication, file permissions, and MCP server connectivity.

Quick Solution

  1. Install the VSCode Dev Containers extension and Docker Desktop.

  2. Create .devcontainer/devcontainer.json in your project root:

{
  "name": "Claude Code Dev",
  "image": "mcr.microsoft.com/devcontainers/typescript-node:20",
  "features": {
    "ghcr.io/devcontainers/features/common-utils:2": {}
  },
  "postCreateCommand": "npm install -g @anthropic-ai/claude-code",
  "mounts": [
    "source=${localEnv:HOME}/.claude,target=/home/node/.claude,type=bind,consistency=cached"
  ],
  "remoteEnv": {
    "ANTHROPIC_API_KEY": "${localEnv:ANTHROPIC_API_KEY}"
  },
  "forwardPorts": []
}
  1. Open the Command Palette and run Dev Containers: Reopen in Container.

  2. Open the integrated terminal and run claude to verify the installation.

  3. Place your CLAUDE.md file in the project root so it is available inside the container automatically.

How It Works

VSCode Dev Containers run your entire development environment inside a Docker container while keeping the editor UI on your host machine. When you mount your ~/.claude directory into the container, Claude Code picks up your authentication tokens and session history without requiring re-authentication.

The postCreateCommand installs Claude Code globally inside the container on first build. Because the container filesystem is ephemeral, this runs each time you rebuild, but cached layers keep it fast.

CLAUDE.md files work normally since they live in the project root, which is automatically mounted as the container workspace. MCP servers defined in your project-level .mcp.json will also be available, though servers that depend on host-level binaries need to be installed inside the container image.

Hooks configured in .claude/hooks/ execute inside the container, giving them access to the same toolchain your code uses. This is especially useful for pre-commit hooks that run linters or formatters.

Common Issues

Authentication fails inside the container. Ensure the ~/.claude directory mount is correct and the ANTHROPIC_API_KEY environment variable is forwarded. Check with echo $ANTHROPIC_API_KEY inside the container terminal.

MCP servers cannot connect. If your MCP server runs on the host machine, you need to forward the port into the container or run the MCP server inside the container itself. Add the server port to forwardPorts in devcontainer.json.

File permission errors on mounted volumes. The container user UID must match your host user UID. Add "remoteUser": "node" and ensure the mount target directory is owned by that user. Alternatively, use "updateRemoteUserUID": true.

Example CLAUDE.md Section

# Docker Dev Container Project

## Environment
- Runtime: Node.js 20 inside devcontainer
- Package manager: pnpm (installed via postCreateCommand)
- Database: PostgreSQL via docker-compose service

## Rules
- All commands run inside the container terminal
- Never modify files in /node_modules or /dist
- Run `pnpm test` before suggesting any commit
- Use relative imports, not absolute paths

## MCP Servers
- Database MCP available on localhost:5433
- File search uses built-in grep (no ripgrep in container)

## Container Notes
- Rebuild container after changing Dockerfile
- Environment variables come from .env.local on host
- Port 3000 is forwarded for dev server

Best Practices



I'm a solo developer in Vietnam. 50K Chrome extension users. $500K+ on Upwork. 5 Claude Max subscriptions running agent fleets in parallel. These are my actual CLAUDE.md templates, orchestration configs, and prompts. Not a course. Not theory. The files I copy into every project before I write a line of code. **[See what's inside →](https://zovo.one/lifetime?utm_source=ccg&utm_medium=cta-default&utm_campaign=claude-code-docker-vscode)** $99 once. Free forever. 47/500 founding spots left.

Related Reading

Built by theluckystrike. More at zovo.one