Claude Code sandbox options: /sandbox, Docker, dev containers and microVMs

Last updated

What each sandbox puts inside the boundary, and whose kernel is under it

/sandbox

boundary

srt, or a container

boundary

A microVM, or a VM

the VM

/sandbox Shell commands

"A boundary that the operating system enforces around the shell commands Claude runs on your machine." It is off by default.

/sandbox File tools, MCP servers, hooks

"Claude's file tools, MCP servers, and hooks run outside it", with your full access. Anthropic says it "is not sufficient for fully unattended runs".

/sandbox Your kernel

Same kernel as your machine: a kernel bug, or a container breakout, can reach your host.

srt, or a container The whole process

srt claude puts the whole Claude Code process inside, so file tools, hooks and MCP servers are fenced too. A dev container moves the whole session into a Docker container.

srt, or a container The sandbox, or the container

srt wraps the process in the same Seatbelt or bubblewrap boundary: by default it denies network access and confines writes to a few runtime paths. A plain container puts it in its own filesystem and network namespace, and egress is open by default: add a firewall or a proxy.

srt, or a container Your kernel

A container "shares the kernel of the machine it runs on", in Docker's words. The sandbox runtime shares your kernel too.

A microVM, or a VM The whole process

Docker Sandboxes starts claude --dangerously-skip-permissions by default, in a microVM per agent. Egress filtering on a VM of your own is yours to set up.

A microVM, or a VM A kernel of its own

Only microVMs and VMs change the kernel row: Docker Sandboxes, a cloud session, a remote VM. Only those give the agent its own kernel.

A microVM, or a VM Your machine, or another one

On another machine, a VM also takes your laptop out of reach: the agent can wreck the VM, not your home directory, and you delete the VM afterwards.

Default settings, from Anthropic's and Docker's documentation, 5 November 2026. Hatched: the kernel of your own machine, shared with the agent.

Claude Code can be sandboxed at four depths: the built-in /sandbox, which fences shell commands only; a container or dev container, which fences the whole Claude Code process but shares your kernel; Docker Sandboxes, a microVM on your machine; and a VM on another machine. Pick by the risk you care about, not by the name "sandbox": the built-in one is for fewer prompts on your own code, and Anthropic says it "is not sufficient for fully unattended runs".

If what worries you is… Use at least Why
Approving every npm test by hand /sandbox in auto-allow mode Sandboxed commands run without a prompt; writes stay in the project
An rm -rf that leaves the project /sandbox (for Bash), or any container Sandboxed commands write only to the project, a temp dir and directories you add
--dangerously-skip-permissions or auto mode, unattended A dev container, the sandbox runtime, Docker Sandboxes or a VM File tools, MCP servers and hooks must be inside the boundary too
Secrets leaving over the network A strict egress allowlist, wherever you run Every layer that allows egress "can still leak data the agent can read"
A kernel or container-runtime exploit A microVM or VM: Docker Sandboxes, a cloud session, a remote VM Only those give the agent its own kernel
An untrusted repository A dedicated VM, or a cloud session Anthropic's own pick for that row

Everything below was checked against Anthropic's and Docker's documentation on 5 November 2026.

What does Claude Code's /sandbox isolate?

/sandbox turns on the sandboxed Bash tool, "a boundary that the operating system enforces around the shell commands Claude runs on your machine". It is off by default. It covers Bash, PowerShell and Monitor commands and the processes they start, and nothing else: "Claude's file tools, MCP servers, and hooks run outside it."

It uses Seatbelt on macOS and bubblewrap plus socat on Linux and WSL2. On native Windows, commands run unsandboxed; run Claude Code inside WSL2 to get it. Under the hood is Anthropic's open-source @anthropic-ai/sandbox-runtime package.

Its default boundary, from the sandboxing docs:

Default
Writes The working directory, a per-user temp directory and directories you added. "Protected paths stay write-denied"
Reads "Most of the machine, including credential files such as ~/.ssh and ~/.aws/credentials"
Network No direct route out: a local proxy checks each host against allowedDomains, which starts empty
Environment Inherited from Claude Code, "including any secrets in its environment"

The protected paths are the files Claude Code loads code and settings from: in the project and above it, the .claude settings and its skills, agents, commands and hooks directories and .mcp.json; in the project, shell startup files such as .bashrc, .gitconfig, .vscode, .idea, and hooks and config inside .git; and most of ~/.claude, including the .credentials.json store.

What runs outside it, with your full access: Read, Edit, Write, WebFetch and WebSearch (they follow permission rules instead: "allowedDomains doesn't limit WebFetch"), command hooks, local MCP servers, plugin monitors, LSP servers, the status line command and apiKeyHelper. The proxy checks hostnames and "does not terminate or inspect TLS traffic", and UDP, QUIC and ping can't leave the sandbox.

Claude Code sandbox mode: auto-allow or regular permissions

The /sandbox panel has three tabs, Mode, Overrides and Config, and two modes:

  • Auto-allow: a command that runs inside the sandbox is approved with no prompt. This is the mode that cuts prompts.
  • Regular permissions: every Bash command goes through the normal permission flow, sandboxed or not.

The sandbox mode is separate from the permission mode. When a sandboxed command connects to a host outside your allowlist, the permission mode decides: you get a prompt in Manual and acceptEdits modes, auto mode refuses it unless the classifier approved that host for the command, dontAsk refuses it, and bypassPermissions lets it through without a prompt, unless sandbox.network.strictAllowlist is on.

A sandboxed command reaches a host outside your allowlist: the permission mode decides

A sandboxed command reaches a host outside your allowlist: the permission mode decides
Permission modeThe connection
ManualPartial: You get a prompt
acceptEditsPartial: You get a prompt
autoStrength: Refused, unless the classifier approved that host for the command
dontAskStrength: Refused
bypassPermissionsGap: Let through without a prompt
Anthropic's sandboxing docs, 5 November 2026. With sandbox.network.strictAllowlist on, unlisted hosts are refused in every permission mode.

Claude Code sandbox settings

The same boundary can live in ~/.claude/settings.json, so it doesn't depend on someone typing /sandbox:

{
  "sandbox": {
    "enabled": true,
    "failIfUnavailable": true,
    "allowUnsandboxedCommands": false,
    "filesystem": {
      "denyRead": ["~/.ssh", "~/.aws"]
    },
    "network": {
      "allowedDomains": ["github.com", "*.npmjs.org"],
      "strictAllowlist": true
    }
  }
}
Key What it does
sandbox.enabled Turns the sandbox on (off by default)
sandbox.failIfUnavailable Exits at startup instead of running unsandboxed when bubblewrap or the platform check fails
sandbox.allowUnsandboxedCommands false ignores the dangerouslyDisableSandbox retry: "strict sandbox mode"
sandbox.autoAllowBashIfSandboxed Auto-approves sandboxed commands (default true)
sandbox.filesystem.allowWrite / denyWrite Extra writable paths / paths never writable
sandbox.filesystem.denyRead / allowRead Paths sandboxed commands can't read / exceptions inside a denied area
sandbox.network.allowedDomains / deniedDomains Hosts sandboxed commands may reach / hosts always refused
sandbox.network.strictAllowlist Refuses unlisted hosts in every permission mode instead of prompting. User, managed or --settings only: a repository's .claude/settings.json can't turn it on or off
sandbox.credentials.files[] / envVars[] Per file or variable, deny it or mask it (masking needs the experimental network.tlsTerminate)
sandbox.excludedCommands Command patterns that run outside the sandbox, such as "docker compose *"

Two traps. denyRead stops sandboxed commands, not the Read tool: add a permission deny rule for that. And if you set allowNestedUserNamespaces to true, Anthropic warns, you "turn off a security boundary". The full list is on Anthropic's sandboxing page.

The sandbox runtime: the whole process, without Docker

The sandbox runtime (srt, Apache 2.0, a "research preview") wraps any process in the same Seatbelt or bubblewrap boundary. srt claude puts the whole Claude Code process inside, so file tools, hooks and MCP servers are fenced too. By default it denies network access and confines writes to a few runtime paths; you allow your project, ~/.claude, ~/.claude.json, the temp directory, api.anthropic.com, and claude.ai plus platform.claude.com if you sign in with a subscription. It blocks writes to .git/hooks, .mcp.json, .claude/commands, .claude/agents and shell startup files at the project root on its own.

It is Anthropic's lightest option for unattended runs, with two limits: reads are allowed everywhere by default, and it shares your kernel. On Linux, its deny list is built once at launch, so a repository the session clones later isn't covered.

Claude Code in Docker, and Docker Sandboxes

A plain container (docker run with the project mounted) puts the whole Claude Code process in its own filesystem and network namespace. Three things to get right:

  • Never mount the Docker socket. Docker's daemon "requires root privileges", and Docker's own advice is that "only trusted users should be allowed to control your Docker daemon". An agent with the socket can start a container that mounts your whole disk.
  • Run as a non-root user. Claude Code refuses --dangerously-skip-permissions as root or under sudo outside a recognized sandbox.
  • Egress is open by default. "Containers have networking enabled by default, and they can make outgoing connections": add a firewall or a proxy.

/sandbox and Docker don't mix well: "docker is incompatible with the sandbox", so Docker commands have to go in excludedCommands, and running bubblewrap inside an unprivileged container needs enableWeakerNestedSandbox. And a container "shares the kernel of the machine it runs on", in Docker's words.

Docker Sandboxes is the other Docker product: a microVM per agent, with "a kernel of its own" and a private Docker daemon, on your machine or on Docker's cloud. The CLI and local sandboxes are "free to use, including for commercial work", and Anthropic notes it doesn't require Docker Desktop. One command:

sbx run claude ~/my-project

That starts claude --dangerously-skip-permissions by default. Sign in with /login inside the session, or store an API key with sbx secret set anthropic: a host-side proxy adds it to requests, and "the raw credential values never enter the VM". Outbound TCP is "blocked unless an explicit rule allows the destination", outbound UDP is off, and DNS goes through a resolver "which enforces network policy". The caveats: "the default allowed domains include broad wildcards" (sbx policy ls shows them), the default direct mount is read-write so the agent "edits your working tree in place" (clone mode avoids that), and local stdio MCP servers run on the host. If one of these rules it out, Docker Sandboxes alternatives sorts the other options by the reason you're leaving.

Claude Code sandbox vs dev container

The built-in sandbox fences commands on your host; a dev container moves the whole session into a Docker container that your editor (VS Code, Codespaces, JetBrains, Cursor) attaches to. Anthropic's reference dev container is three files in the anthropics/claude-code repository:

  • devcontainer.json: runs as the non-root node user, bind-mounts your project at /workspace, keeps ~/.claude in a named volume, adds the NET_ADMIN and NET_RAW capabilities, and runs the firewall at each start;
  • Dockerfile: the base image, tools and the Claude Code install;
  • init-firewall.sh: default policy DROP on input, forward and output.

Read the firewall's allowlist before you trust it. It allows registry.npmjs.org, api.anthropic.com, sentry.io, statsig.com, three VS Code domains, and every IP range GitHub publishes for its web, API and git services. It also accepts outbound DNS (UDP 53) and SSH (TCP 22) to any host, and the host's /24. So a git push to any repository on GitHub goes out, and so does data encoded in DNS lookups.

Anthropic's own warning: with --dangerously-skip-permissions, dev containers "do not prevent a malicious project from exfiltrating anything accessible inside the container, including the Claude Code credentials stored in ~/.claude". The project is bind-mounted, so a deletion or a planted .git/hooks file inside it lands on your disk. Use it for trusted repositories, and mount no host secrets.

/sandbox Reference dev container
What's inside the boundary Shell commands The whole Claude Code process, MCP servers and hooks included
Needs Docker No Yes
Your home directory Readable by commands, not writable Not there unless you mount it
Network Proxy, empty allowlist; bypass mode lets unlisted hosts through without strictAllowlist iptables allowlist; DNS and SSH open to any host
Kernel Yours Yours (shared with the container)
Good for Fewer prompts on your own code A team-wide environment, unattended runs on trusted repos

A remote microVM

A virtual machine is the strongest option in Anthropic's list, "with its own kernel and, in cloud or microVM deployments, its own virtualized hardware". On another machine, it also takes your laptop out of reach: the agent can wreck the VM, not your home directory, and you delete the VM afterwards.

Two kinds:

  • Anthropic's cloud sessions run in an Anthropic-managed VM. "A network proxy enforces a default allowlist, and a separate proxy holds your GitHub token outside the sandbox." They need a Claude subscription. Claude Code in the cloud covers when they fit.
  • A VM of your own: a cloud instance, a VPS, or a Firecracker microVM service. You choose the image, the size and what's installed, and egress filtering is yours to set up. Claude Code on a remote server walks through the setup over SSH.

flockvm is one of the second kind, and the product this site is about. Each VM is a Firecracker microVM with its own kernel, on one host in France. The default Agent image has Claude Code preinstalled and logs you in as the non-root user, so --dangerously-skip-permissions works. You sign in with /login inside the session in the VM, or give the VM your organization's Anthropic API key through an environment. What it doesn't do yet: outbound IPv4 is open (only private ranges, cloud metadata, other VMs, the host and SMTP port 25 are blocked), and there is no egress allowlist and no secrets proxy. So a flockvm VM protects your machine and gives each agent its own kernel; it doesn't stop an agent from sending out what it can read inside the VM.

What does each Claude Code sandbox block?

Default settings, from each vendor's documentation on 5 November 2026. This describes design, not an attack we ran.

Risk /sandbox Sandbox runtime (srt claude) Docker container Reference dev container Docker Sandboxes Remote microVM (flockvm today)
Deleting files outside the project Blocked for shell commands; the Edit and Write tools follow permission rules Blocked: writes only where you allow Blocked unless mounted Blocked unless mounted Blocked: nothing outside the workspace is shared Not reachable: your machine isn't there
Deleting or poisoning the project Writable; protected paths (.git/hooks, .claude/, .mcp.json) are not, for commands Writable; .git/hooks, .mcp.json and shell startup files denied Writable through the mount Writable, and it's your host's folder Writable in place by default; clone mode keeps a private clone Writable, but it's the VM's copy
Reading secrets Commands read most of the machine, ~/.ssh included, unless denyRead or sandbox.credentials Reads allowed everywhere by default What's in the container What's in the container, ~/.claude included The VM's files; keys stored with sbx secret stay on the host What's in the VM: your laptop's files aren't
Network egress Allowlist via proxy; open in bypass mode without strictAllowlist; WebFetch not covered Denied by default; allowlist Open by default Allowlist, plus DNS and SSH to any host Deny by default, broad default wildcards Open IPv4, except private ranges, metadata, other VMs, the host, port 25
Kernel or runtime exploits Same kernel as your machine Same kernel Same kernel as the host Same kernel as the host Own kernel per sandbox Own kernel per VM, on another machine

What the table says:

  • Nothing on this list stops a prompt injection. It only limits what a followed injection can reach.
  • Egress is the weak spot everywhere. Anthropic: "Any approach that allows network egress can still leak data the agent can read." The fix is a short hostname allowlist, wherever you run.
  • Only microVMs and VMs change the kernel row. In the first four columns, a kernel bug, or a container breakout, can reach your host. MicroVM vs container explains why.

For the same layers tested against seven concrete attacks (DNS leaks, a git push with a planted token, .git/hooks), see running Claude Code with --dangerously-skip-permissions safely.

What is the best Claude Code sandbox?

There isn't one best; there is one per situation:

  • Your own code, at your desk, fewer prompts: /sandbox in auto-allow mode, with failIfUnavailable, allowUnsandboxedCommands: false and strictAllowlist in user settings.
  • Unattended on your laptop, no Docker: srt claude, with a written allowlist.
  • A whole team, one setup: Anthropic's dev container, with the firewall's allowlist trimmed.
  • Unattended on your laptop, with host-held API keys: Docker Sandboxes.
  • Untrusted code, or agents that should run without your laptop: a VM elsewhere, a cloud session or your own.

You can stack them: /sandbox inside a container or VM adds per-command limits on top of the outer boundary.

Which sandbox, for which situation

What is your situation?

Your own code, at your desk, fewer prompts

/sandbox in auto-allow mode

With failIfUnavailable, allowUnsandboxedCommands: false and strictAllowlist in user settings. Anthropic says it "is not sufficient for fully unattended runs".

Read that part

Unattended on your laptop, no Docker

srt claude

With a written allowlist. It is Anthropic's lightest option for unattended runs, with two limits: reads are allowed everywhere by default, and it shares your kernel.

Read that part

A whole team, one setup

Anthropic's dev container

With the firewall's allowlist trimmed. Use it for trusted repositories, and mount no host secrets.

Read that part

Unattended on your laptop, with host-held API keys

Docker Sandboxes

A microVM per agent, with "a kernel of its own". A host-side proxy adds the key to requests, and "the raw credential values never enter the VM".

Read that part

Untrusted code, or agents that should run without your laptop

A VM elsewhere

A cloud session or your own. The agent can wreck the VM, not your home directory, and you delete the VM afterwards.

Read that part

You need an egress allowlist or a secrets proxy today

Docker Sandboxes or a cloud session

flockvm has neither yet; Docker Sandboxes and Anthropic's cloud sessions do.

Read that part

The five situations of this section, each with the limit the page gives for its pick, and the case where the page says others do more than flockvm.

When flockvm is the wrong pick

  • You need an egress allowlist or a secrets proxy today. flockvm has neither yet; Docker Sandboxes and Anthropic's cloud sessions do.
  • You run one agent on your own code. /sandbox or a dev container costs nothing and needs no remote machine.
  • You need many VMs at once. The host in France runs 15 small VMs (2 vCPU / 4 GiB) at once, across all customers, 2 during the trial; it is the one region today, and others are planned.
  • You'd rather Anthropic run the VM. That's a cloud session, which needs a Claude subscription.

If you want a throwaway Firecracker VM per agent, with Claude Code already installed, flockvm bills per second ($0.016 an hour for a small VM on 5 November 2026) against an $18 monthly plan that comes back as VM time. The 7-day free trial needs a card and charges nothing for 7 days. Claude Code in a VM shows the setup.

FAQ

Is the Claude Code sandbox on by default?

No. Run /sandbox in a session or set sandbox.enabled: true in a settings file. Without sandbox.failIfUnavailable: true, a missing dependency means commands run unsandboxed.

Does /sandbox work with --dangerously-skip-permissions?

It stays active, but in bypass mode a host outside your allowlist is "allowed without a prompt" unless sandbox.network.strictAllowlist is on. File tools, MCP servers and hooks stay outside it either way. Anthropic's rule for that flag: "Always run --dangerously-skip-permissions sessions inside a container, a VM, or the sandbox runtime."

Does the Claude Code sandbox work on Windows?

Not natively: on native Windows, commands run unsandboxed. Run Claude Code inside WSL2, or in a container or VM.

Is a dev container a sandbox?

It isolates the whole session from your host's files, but not your project folder (bind-mounted) and not your kernel. With the reference firewall it also limits egress, with DNS, SSH and all of GitHub left open.

Does a sandbox send less of my code to Anthropic?

No. "Isolation also does not change what is sent to the model": the files Claude reads go to the API with or without a sandbox.

Can Claude Code use Docker inside the sandbox?

Not inside /sandbox: Docker commands have to be excluded and then run unsandboxed. Docker Sandboxes and VMs, flockvm's included, have their own Docker daemon, so docker build and docker compose work inside the boundary.

Run your agents in their own microVMs

flockvm gives each coding agent a Firecracker microVM that pauses with its memory and resumes, billed per second. France is live, and you can start with a 7-day free trial.

Start your 7-day free trial

Card required. Nothing charged for 7 days.