Issue 00 · Autumn 2026日本語 · RSS
AgentKoji

PRSome articles contain affiliate links. If you sign up through them we may earn a commission. It never changes the verdict. Affiliate Disclosure

Run Claude Code in Docker and Dev Containers

The official reference container blocks all outbound traffic except an allowlist. How to isolate Claude Code in a dev container, keep your login, and stay safe.

TL;DR

  • Inside a Docker dev container, Claude's commands run in the container while edits to project files still show up in your local repository.
  • Install with the official Dev Container Feature; its :1.0 tag pins the install script, not the Claude Code release. To pin a version, use npm in the Dockerfile and set DISABLE_AUTOUPDATER=1.
  • We checked config files and read the reference container but did not build or run a container for this guide.

PR: This article contains affiliate links (VPS). We chose them by region and billing model only, and payouts don’t change our assessment.

When Claude Code runs inside a Docker container, the commands Claude executes run in the container, not on your machine. Edits to project files still show up in your local repository. This guide uses the official dev container setup to cover installing Claude Code, keeping your login across rebuilds, restricting outbound traffic, the caveats of running without permission prompts, and what’s in the official reference container. In our test environment (macOS, Docker 29.8.2, on 2026-10-20), we checked the config files with jq and read the reference container’s files. We did not build or start a container, or run Claude Code inside one (not run).

How dev containers work

A dev container is a development environment defined as a Docker container, so everyone on a team gets the same setup. Editors that support the Dev Containers spec, such as VS Code, GitHub Codespaces and JetBrains IDEs, connect to it. You edit files in the editor as usual, but the integrated terminal and build tools run inside the container. Your local repository is bind-mounted into the container as the workspace.

(source: https://code.claude.com/docs/en/devcontainer, checked 2026-10-20)

Install Claude Code

Use the official Dev Container Feature. Put this in .devcontainer/devcontainer.json in your repository:

{
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
  "features": {
    "ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {}
  }
}

The :1.0 tag pins the Feature’s install script, not the Claude Code release. The Feature installs the latest Claude Code, which then auto-updates inside the container. To pin a version, skip the Feature, run npm install -g @anthropic-ai/[email protected] in your Dockerfile, and set DISABLE_AUTOUPDATER to 1 in containerEnv.

In VS Code, run Dev Containers: Rebuild Container from the Command Palette, then run claude in the container’s terminal and sign in. If the browser sign-in finishes but never returns to the container, paste the code the browser shows at the Paste code here if prompted prompt.

(source: https://code.claude.com/docs/en/devcontainer, checked 2026-10-20)

We put the devcontainer.json above into a dummy todo app and confirmed it parses as JSON with jq. We did not build it (not run).

Keep your login and settings

Rebuilding the container wipes its home directory, so by default you sign in again after every rebuild. Claude Code keeps its auth token, user settings and session history in ~/.claude, but your OAuth account and trust settings live in a separate ~/.claude.json. Mounting a volume at ~/.claude alone won’t keep you signed in. The docs say to mount the volume and point CLAUDE_CONFIG_DIR at it:

{
  "mounts": [
    "source=claude-code-config-${devcontainerId},target=/home/node/.claude,type=volume"
  ],
  "containerEnv": {
    "CLAUDE_CONFIG_DIR": "/home/node/.claude"
  }
}

/home/node assumes the container’s remoteUser is node. Including ${devcontainerId} in the name gives each project its own volume, which is what the reference container does.

(source: https://code.claude.com/docs/en/devcontainer, checked 2026-10-20)

Restrict outbound traffic

The reference container ships init-firewall.sh, which limits outbound traffic to an allowlist. Reading the script, we found it sets every default policy to DROP, then allows GitHub’s IP ranges and these domains:

registry.npmjs.org
api.anthropic.com
sentry.io
statsig.com
marketplace.visualstudio.com
vscode.blob.core.windows.net
update.code.visualstudio.com

It finishes by checking that https://example.com is unreachable and https://api.github.com is reachable. Running a firewall inside a container needs extra privileges, so the reference adds the NET_ADMIN and NET_RAW capabilities through runArgs. According to the docs, Claude Code itself doesn’t need the script or the capabilities; you can rely on your own network controls instead.

(sources: https://code.claude.com/docs/en/devcontainer and https://github.com/anthropics/claude-code/blob/main/.devcontainer/init-firewall.sh, checked 2026-10-20)

Running without permission prompts

The container runs Claude Code as a non-root user and keeps command execution inside the container, so you can pass --dangerously-skip-permissions for unattended runs. The CLI rejects the flag when launched as root, so make sure remoteUser is not root.

A container doesn’t protect everything. The docs list these limits:

If you only want fewer prompts, auto mode has a classifier review each action before it runs. To ban --dangerously-skip-permissions across an organization, set permissions.disableBypassPermissionsMode to "disable" in managed settings.

(source: https://code.claude.com/docs/en/devcontainer, checked 2026-10-20)

For permission rule syntax, see Claude Code Permissions and settings.json: A Cheat Sheet. For handling secrets, see Keep Secrets Away from Claude Code.

Isolating on a server instead

Instead of local Docker, you can isolate Claude Code on a separate server. That keeps it physically apart from the secrets on your own machine.

VPS options (Japan-focused services): ConoHa VPS offers a Tokyo region with hourly billing, and XServer VPS lets you choose plans by memory size. Both are Japanese providers. Plans and prices change, so check their official pages before you sign up.

For running an agent on a VPS around the clock, see Run an AI Agent 24/7 on a VPS.

The official reference container

The anthropics/claude-code repository includes a reference dev container that combines the CLI, the egress firewall, persistent volumes and a Zsh shell. The docs describe it as a working example, not a maintained base image.

FileWhat it holds
devcontainer.jsonVolume mounts, runArgs capabilities, VS Code extensions, containerEnv
DockerfileBase image (node:20), dev tools, npm install -g @anthropic-ai/claude-code
init-firewall.shLimits outbound traffic to an allowlist

In devcontainer.json, we found remoteUser set to node, with postStartCommand running sudo /usr/local/bin/init-firewall.sh on every start. The Dockerfile lets the node user run only that script with sudo.

(sources: https://code.claude.com/docs/en/devcontainer and https://github.com/anthropics/claude-code/tree/main/.devcontainer, checked 2026-10-20)

Summary

Some articles contain affiliate links. If you sign up through them we may earn a commission. It never changes the verdict. Affiliate Disclosure