okayus/okayus-skills/claude-code-docker-sandbox

Claude Code and agent skill by okayus/okayus-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Set up a Docker Compose-isolated development environment where dependency installs and agent-run code execute behind a default-deny network firewall, never touching the host. Use when you want to run `npm install` / `cargo build` / `cabal build` / `go build`, untrusted dependencies, or Claude Code itself in a container to contain supply-chain attacks — without depending on VS Code. Reuses Anthropic's published devcontainer Dockerfile + init-firewall.sh, driven by a plain docker-compose.yml so any host editor works via bind mount; Rust/Haskell/Go toolchains are opt-in build args on the node:24 (LTS) base. Covers the egress allowlist (fatal vs OPTIONAL non-fatal domains), build-time-vs-runtime network, keeping Claude Code current inside the firewall (native updater's host is blocked — update via npm at start), why the /model picker hides flag-gated models until DISABLE_TELEMETRY is unset, bypassPermissions-by-default (container-scope, not repo-shared), and host-side git hygiene.

Install

npx vskill@latest install okayus/okayus-skills/claude-code-docker-sandbox

SKILL.md

The same SKILL.md was published earlier as okayus/okayus-skills/claude-code-docker-sandbox.

Claude Code Docker Sandbox

Get a Node/JS project to the state where `npm install`, build tools, and Claude Code all run inside a container behind a default-deny iptables firewall, while you edit files from your normal host editor and run git on the host.

Why do this: supply-chain attacks execute arbitrary code at dependency-install/build time and at run time — npm postinstall scripts, Rust build.rs, Haskell custom Setup.hs, Go go generate / malicious module code in tests are all the same class of hole. A naked npm install / cargo build / cabal build / go build on the host can read ~/.ssh, ~/.aws/credentials, exfiltrate over the network, or backdoor your shell rc files. This skill confines all of that to a container whose only network egress is an explicit allowlist (the package registry, GitHub, your model API, your deploy target) — everything else is rejected at the OS level.

Languages: the base image is node:24 (current Node LTS) because Claude Code itself is an npm package and needs a Node runtime even in a Rust-, Haskell-, or Go-only project. It must be a Node ≥ 22 line: @anthropic-ai/claude-code@latest now declares engines.node >=22, so an older base like node:20 installs with an EBADENGINE warning and the in-container agent misbehaves — pin the base to the current LTS and bump the major as new LTS lines land. Rust (rustup), Haskell (GHCup), and Go (official tarball) are opt-in `--build-arg` layers on top — see Language toolchains.

This is the non-VS-Code path. Anthropic's official .devcontainer/ reference assumes a VS Code / Dev Containers spec editor. Here the same hardened Dockerfile + init-firewall.sh are driven by a plain docker-compose.yml, so the workflow is docker compose exec dev zsh + any host editor.

When to use this skill

  • Starting a new Node/JS/TS project and you do not want npm install to run on the host
  • You use nvim / helix / emacs / any non-VS-Code editor and the official dev container flow doesn't fit
  • You want to run Claude Code (or another coding agent) with reduced permission friction, knowing an OS-level boundary contains it
  • You're spooked by a recent npm compromise and want a repeatable isolation baseline across projects

Do not use this when: you need the full VS Code Dev Containers UX (use the official .devcontainer/ instead), you're on native Windows without WSL2 (the firewall needs Linux netfilter — run inside WSL2 or a Linux VM), or you require kernel-level separation against truly untrusted code (use a VM/microVM instead — a container shares the host kernel).

Threat model & limits (read before relying on it)

  • What it stops: postinstall scripts and run-time code from writing outside the project dir, reading host home/credentials, or reaching non-allowlisted network hosts. Blast radius of a malicious package is the bind-mounted project dir + the allowlisted domains.
  • What it does NOT stop: data exfiltration through an allowlisted domain (e.g. pushing secrets to a GitHub repo you allowed — the firewall filters by hostname, not by intent), kernel exploits (shared kernel), or anything you mount writable. Keep the allowlist narrow and never mount host secrets (~/.ssh, cloud cred files) into the container.
  • git push stays on the host. Don't put git credentials in the container. The agent inside can read git status/git log (the .git dir is bind-mounted) but you run commit/push from the host. This keeps your GitHub token out of the isolation boundary. Two documented ways to let the agent push anyway: credential-free via sandboxed-agent-git-relay (host-side relay + GitHub App), or — accepting a repo-scoped, expiring token inside the boundary — sandboxed-agent-github-token-via-1password (fine-grained PAT resolved from 1Password at docker compose up, env only, never on disk).

Deliverables (completion criteria)

You're done when:

  1. docker compose up -d starts the container and the logs contain Firewall verification passed - unable to reach https://example.com as expected followed by ... able to reach https://api.github.com as expected (they won't be the last lines — the startup npm i -g / tooling output comes after).
  2. docker compose exec dev sh -c 'curl --connect-timeout 5 -s -o /dev/null -w "%{http_code}" https://example.com' prints 000 (blocked), and the same against https://registry.npmjs.org prints 200.
  3. docker compose exec dev zsh drops you into /workspace as the non-root node user, and your project files are visible there (bind mount works).
  4. Inside the container, claude authenticates successfully and /status shows the model — and survives docker compose down && docker compose up -d (auth persisted in the claude-config volume).
  5. Host-side edits to project files appear inside the container without a rebuild.
  6. The first message of a fresh in-container claude session already contains the repo's docs/status.md (injected by the committed SessionStart hook from `agent-status-hub`) — the agent knows where the project stands without being told.

Setup order

Copy the three template files into your repo, then build and verify. Full commented copies are in references/.

  1. `.docker/Dockerfile` — copy references/Dockerfile verbatim. It is Anthropic's published devcontainer image (base bumped to node:24 LTS): non-root node user, dev tools, git-delta, zsh+powerlevel10k, @anthropic-ai/claude-code installed globally, and a passwordless-sudo rule scoped to only init-firewall.sh.
  1. `.docker/init-firewall.sh` — copy references/init-firewall.sh. Edit the for domain in ... allowlist (see Tuning the allowlist) to match what your project actually needs. GitHub IP ranges are fetched dynamically; you only list extra domains.
  1. `docker-compose.yml` — copy references/docker-compose.yml into the repo root. Replace the <project> placeholder in container_name. Adjust the published port (5173 = Vite default) to your dev server. For a Rust/Haskell/Go project, set INSTALL_RUST/INSTALL_HASKELL/INSTALL_GO to "true" here and uncomment the matching registry block in step 2 — see Language toolchains.
  1. Build & start:

``sh docker compose build # 5–10 min first time (apt, zsh-in-docker, claude install) docker compose up -d docker compose logs dev # confirm the two "Firewall verification passed" lines ` If docker compose build fails with dial tcp: lookup production.cloudfront.docker.com ... server misbehaving, that's a transient Docker Hub DNS hiccup — just re-run docker compose build`.

  1. Authenticate Claude Code inside the container — follow references/authentication.md. The key trap: the OAuth localhost callback can't reach the container, so you copy the URL to a host browser and paste the returned code back at the Paste code here if prompted prompt.
  1. Verify against the deliverables above.
  1. Give the in-container agent its bearings — apply `agent-status-hub` before the first autonomous loop: a hard-capped docs/status.md injected by a SessionStart hook in the committed .claude/settings.json, written back with /handoff, capped in CI. Everything is in the repo (bind-mounted at /workspace), so the container needs no rebuild and no extra mount. This matters more in the sandbox than on the host: the container's auto memory and session transcripts live in the claude-config volume and never reach the host, so repo files are the only context both sides share.

Tuning the egress allowlist

init-firewall.sh sets default-deny and only permits: DNS, SSH, localhost, the host /24, dynamically-fetched GitHub ranges, plus the domains you list in the for domain in ... loop. The template ships with:

sh
for domain in \
"registry.npmjs.org" \
"api.anthropic.com" \
"api.cloudflare.com" \
"dash.cloudflare.com" \
"workers.cloudflare.com"; do
  • `registry.npmjs.org` — required for npm install.
  • `api.anthropic.com` — required for Claude Code to reach the model. (Using Bedrock/Vertex/Foundry instead? Swap in that provider's endpoint.)
  • Cloudflare entries — only if you deploy to Cloudflare. Drop them otherwise.
  • Add the registry of any other package manager (registry.yarnpkg.com), private registries, or CDN hosts your toolchain fetches from at runtime.
The telemetry-domain DNS trap — and the OPTIONAL list that defuses it. The main loop does exit 1 if any listed domain fails to resolve, and that failure kills the container (the firewall is the entrypoint). Anthropic's reference list includes statsig.anthropic.com, sentry.io, and VS Code Marketplace domains — and statsig.anthropic.com doesn't even exist anymore (no A record), so blindly copying it guarantees the failure path. The template therefore has a second, non-fatal OPTIONAL loop: a failed resolve there logs a WARN and continues. Put nice-to-have egress in it — the real Statsig endpoints (statsig.com, api.statsig.com, featuregates.org, statsigapi.net, prodregistryv2.org — one shared anycast IP) and your production hostname, so the in-container agent can verify its own deploys (curl /health). Keep sentry.io and VS Code domains out entirely.
The /model picker hides flag-gated models — env is the lever, not egress. The picker's roster is driven by Statsig feature flags. With the CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 umbrella set, new flag-gated models (e.g. Fable 5) silently never appear, even though --model <id> works (entitlement is server-side). Fix: split the umbrella into its parts — keep DISABLE_AUTOUPDATER=1, DISABLE_FEEDBACK_COMMAND=1, DISABLE_ERROR_REPORTING=1, leave DISABLE_TELEMETRY unset (the compose template does this). Empirically the flags arrive via api.anthropic.com, so the picker works even if Statsig egress stays blocked; the optional Statsig entries just let the telemetry uploads succeed too.
Two robustness fixes are baked into the template (learned from real failures; keep them):
- `dig` retry. The embedded Docker DNS can intermittently time out at start — worse when several sandboxes come up at once. A single failed dig would exit 1 and kill the container, so the resolve loop retries up to 5×. This is the safety net the telemetry-trap note above warns you need.
- `curl` retry for the GitHub meta fetch. The same first-query DNS hiccup hits
gh_ranges=$(curl -s https://api.github.com/meta) before the allowlist loop — and that
one has no retry, so set -e kills the container with curl's exit code 6 right after
Fetching GitHub IP ranges... (seen on a first docker compose up -d, 2026-08-22). The
template now uses --retry 5 --retry-all-errors --retry-delay 2 … || true and lets the
existing empty-response check report the failure explicitly.
- `ipset add -exist`. Providers like Cloudflare serve many hostnames from a shared anycast IP. The same IP can already be in the set from an earlier domain; without -exist the duplicate add returns non-zero and set -e kills the container mid-config. Corollary: because filtering is IP-based, you cannot allow one anycast hostname while blocking another that resolves to the same IP (e.g. docs.mcp.cloudflare.com vs bindings.mcp.cloudflare.com). Control which servers are used at the app layer (e.g. .mcp.json), not the firewall.

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/okayus/okayus-skills/claude-code-docker-sandbox/badge)](https://verified-skill.com/skills/okayus/okayus-skills/claude-code-docker-sandbox)

Something wrong with this skill or its page? Tell us.