Black Friday: Pro and Max at half price with double the minutes. Ends in See the deal

    BlogGuide

    Claude Code Sandbox: /sandbox, Docker, Dev Containers and Cloud VMs

    By Utpal Nadiger · Updated November 27, 2026

    A Claude Code sandbox limits what the agent's commands can touch, and Anthropic documents six ways to build one, from the built-in /sandbox command to a full cloud VM. The built-in Bash sandbox is off by default, takes one command to enable, and confines shell commands to your working directory with network access through an allowlist that starts empty. If you want to run --dangerously-skip-permissions, Anthropic's guidance is to always do it inside a container, a VM or the sandbox runtime, never on your bare laptop.

    This guide covers each option, what it isolates, and when to pick it.

    Claude Code sandbox options compared

    Anthropic's sandbox environments page lists these approaches:

    ApproachWhat is isolatedNeeds DockerSetup effort
    Bash sandbox (/sandbox)Bash, PowerShell and Monitor commands and their child processesNoMinimal on macOS, low on Linux and WSL2
    Sandbox runtime (srt)The whole Claude Code process, including file tools, MCP servers and hooksNoLow
    Dev containerFull development environmentYesMedium
    Custom containerFull development environmentYesMedium to high
    Virtual machineFull operating systemNoHigh
    Cloud sessionsShell commands and file edits in an Anthropic-hosted VMNoNone, needs a Claude subscription

    The key distinction is the first row against the rest. The Bash sandbox only wraps shell commands. Everything below it wraps Claude Code itself.

    The built-in /sandbox command

    Run this in a session:

    /sandbox

    The panel shows whether dependencies are present and lets you pick a mode. To turn it on for every session, set sandbox.enabled to true in ~/.claude/settings.json. Per the sandboxing docs, the operating system enforces the boundary: Seatbelt on macOS, and bubblewrap plus socat on Linux and WSL2. Native Windows isn't supported, so use WSL2 or a container there.

    # Linux and WSL2 dependencies
    sudo apt-get install bubblewrap socat

    What the defaults do:

    • Filesystem. Commands can write to the working directory and temp locations. Writing elsewhere, such as your home directory, fails.
    • Network. There is no direct route out. Connections go through a local proxy that checks each host against network.allowedDomains, which starts empty.
    • Modes. Auto-allow runs sandboxed commands without prompting. Regular permissions keeps the prompts even for sandboxed commands.

    What it does not cover matters just as much. The built-in Read, Edit, Write, WebFetch and WebSearch tools follow permission rules instead of the sandbox, and MCP servers and hooks run outside it. A denyRead entry in the sandbox doesn't stop the Read tool. When a command fails inside the sandbox, Claude can ask to retry it unsandboxed. To close that escape hatch, start Claude Code with strict settings:

    claude --settings '{"sandbox": {"enabled": true, "allowUnsandboxedCommands": false}}'

    The Bash sandbox is the right tool for cutting down permission prompts on your own machine. It is not a boundary for unattended runs.

    The sandbox runtime: wrap the whole process

    Claude Code's sandbox is built on the open source @anthropic-ai/sandbox-runtime package. You can use it directly to put the entire Claude Code process, including file tools, MCP servers and hooks, behind one boundary, without Docker:

    npm install -g @anthropic-ai/sandbox-runtime
    srt claude

    Configure it in ~/.srt-settings.json first. With no settings file it still starts, but it blocks the network and confines writes to a few runtime paths, so a clean start doesn't prove your config loaded.

    Claude Code in Docker and dev containers

    For a full environment, run Claude Code in a container. Anthropic publishes a dev container feature that installs the CLI into any dev container:

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

    The reference dev container in the claude-code repository goes further, with a default-deny firewall script that only allows approved egress. Because it blocks unapproved traffic, Anthropic says this setup supports running --dangerously-skip-permissions for unattended work.

    Two cautions from the same docs:

    • Credentials inside the container are reachable. With skip-permissions on, Claude can read anything in the container, including its own credentials under ~/.claude. Only mount what the task needs.
    • Persist login with a volume. Mount a volume at ~/.claude (and set CLAUDE_CONFIG_DIR) so you don't sign in on every rebuild.

    If you prefer a microVM to a container, Anthropic also points to Docker Sandboxes, a free standalone product from Docker that gives each sandbox its own Docker daemon.

    Running --dangerously-skip-permissions safely

    --dangerously-skip-permissions is the same as --permission-mode bypassPermissions. Claude stops asking before it acts. Anthropic's permission modes page lists the full set:

    ModeWhat runs without askingSuggested use
    defaultFile reads in your working directoriesSensitive work, unfamiliar code
    acceptEditsReads, file edits and common filesystem commandsIterating on code you review
    planReads, then a plan for you to approveExploring before changing anything
    autoEverything, with background safety checksLong tasks with fewer prompts
    dontAskReads and pre-approved tools, everything else deniedLocked-down CI and scripts
    bypassPermissionsEverythingIsolated containers and VMs only

    A checklist for skip-permissions:

    1. Run it inside a container, VM or srt, so file tools, MCP servers and hooks are inside the boundary too.
    2. Run as a non-root user. On Linux and macOS, Claude Code refuses to start with this flag as root.
    3. Restrict outbound network to the hosts the task needs.
    4. Keep production secrets and personal SSH keys out of the environment.
    5. Treat the machine as disposable. Rebuild it rather than cleaning it.

    Deny rules still apply in every mode, so keep a deny list for things like rm -rf and pushes to main.

    Cloud machines as a sandbox

    The simplest disposable environment is one you never had on your laptop. Claude Code's cloud sessions at claude.ai/code run each session in an Anthropic-managed VM, with no separate charge on Pro, Max, Ultra, Team and Enterprise plans. Work counts toward your usage limits. Cloning and pull requests need GitHub. See how to run Claude Code remotely for the details.

    A cloud VM you rent yourself works too, with the same checklist as above. You pay for the box, keep it patched, and decide what credentials live on it.

    Claude Code on its own cloud machine with OpenComputer

    OpenComputer runs Claude Code on a cloud Linux machine dedicated to your Slack workspace, so the agent never runs on a developer laptop. There is one machine per workspace, sized to your plan, and each Slack thread gets its own git worktree and branch on it. The machine resumes warm, so dependencies and build caches stay between tasks.

    You choose the permission mode per session, from asking before each tool call to plan mode to running without prompts, and approvals and plans show up in the Slack thread for anyone there to answer. Secrets are set per workspace rather than living in someone's dotfiles. Work comes in from @Computer in Slack, the web app or the API, and finished work arrives as a GitHub pull request explaining what changed and how it was checked.

    It is open source and self-hostable. As of November 2026, hosted plans are Pro at $20 a month for 2,000 work minutes and Max at $200 a month for 25,000. See OpenComputer vs Claude Code for how it compares with Claude Code on the web.

    Which sandbox should you use?

    • Fewer prompts during normal work on your laptop: /sandbox in auto-allow mode.
    • Isolate MCP servers and hooks without Docker: srt claude.
    • A team-standard, reproducible setup: the reference dev container, copied into the repo.
    • Unattended runs with skip-permissions: a dev container with the firewall, a VM, or a cloud machine.
    • No local setup at all: cloud sessions or a cloud agent. Compare options in cloud coding agents compared.

    FAQ

    Is the Claude Code sandbox on by default?

    No. The Bash sandbox is off by default. You turn it on by running the sandbox command in a session or by setting sandbox enabled to true in your settings file. Once on, it applies to shell commands and the processes they start.

    Does /sandbox protect against everything Claude does?

    No. It only wraps Bash, PowerShell and Monitor commands. The built-in file tools, web fetches, MCP servers and hooks follow permission rules or run outside it. To put everything behind one boundary, run the whole process in a container, a VM or the sandbox runtime.

    Can I run Claude Code in Docker?

    Yes. Anthropic publishes a dev container feature that installs the CLI and a reference dev container with a default-deny firewall. Any container works if you run it as a non-root user and mount only the files and credentials the task needs.

    Is --dangerously-skip-permissions safe?

    It is safe enough inside a disposable, isolated environment with restricted network access and no valuable credentials. It is not safe on your everyday machine, because Claude can then run any command, edit any file and reach any host without asking first.

    Does the sandbox work on Windows?

    Not natively. On Windows, Anthropic suggests running the Bash sandbox inside WSL2, which needs bubblewrap and socat installed, or running Claude Code in a container or virtual machine instead.

    Sources

    Ship your next change from Slack.

    Add it to Slack, then mention @Computer in any channel.