AI News Daily한국어
← AI tool tips
Claude Code✓ Confirmed in official docsAdded Nov 25

How to run Claude Code in a dev container with an egress firewall

Install Claude Code in a dev container and the commands Claude runs execute inside the container instead of on your machine, while file edits still show up in your local repository. On November 24, developer Milan Jovanović shared a setup that moves Claude Code into a container on a VPS, blocks outbound traffic except to Claude, GitHub and NuGet, and drives it from a phone with Remote Control. The official docs walk through it like this.

  1. Create .devcontainer/devcontainer.json in your repository and add the Claude Code Feature.
{
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
  "features": {
    "ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {}
  }
}
  1. Run Dev Containers: Rebuild Container from the VS Code Command Palette, then run claude in the container terminal and sign in.

  2. To avoid signing in again after every rebuild, mount a volume at ~/.claude and set CLAUDE_CONFIG_DIR to the same path. This example is for a container whose remoteUser is node.

"mounts": [
  "source=claude-code-config,target=/home/node/.claude,type=volume"
],
"containerEnv": {
  "CLAUDE_CONFIG_DIR": "/home/node/.claude"
}
  1. To restrict outbound traffic, copy the official reference container (the .devcontainer/ folder in the anthropics/claude-code repository). Its init-firewall.sh only allows traffic to the destinations the script lists. Running a firewall inside the container needs these capabilities in runArgs.
"runArgs": [
  "--cap-add=NET_ADMIN",
  "--cap-add=NET_RAW"
]

Because the container runs Claude Code as a non-root user, you can pass --dangerously-skip-permissions for unattended runs (the CLI rejects the flag when launched as root). Claude can still modify any file in the bind-mounted workspace, and a malicious project could exfiltrate the Claude Code credentials in ~/.claude inside the container. Use it only with trusted repositories and don't mount host secrets such as ~/.ssh.

Get notified when a new tip lands

Tip alerts only go out in the app. Install it and turn notifications on.

Get the app

All tips →