# How to run Claude Code in a sandbox

DevFeed: [How to run Claude Code in a sandbox](<https://devfeed.tech/articles/how-to-run-claude-code-in-a-sandbox-119457.md>)

Original publisher: [Read original article](<https://nirmata.com/2026/10/31/how-to-run-claude-code-in-a-sandbox/>)

Author: Ritesh Patel

Published: 2026-10-31T19:00:00Z

Content type: tutorial

Language: en

Sources: [Nirmata](<https://devfeed.tech/sources/nirmata.md>)

Topics: [AI Sandbox](<https://devfeed.tech/topics/ai-sandbox.md>), [Claude Code](<https://devfeed.tech/topics/claude-code.md>), [code security](<https://devfeed.tech/topics/code-security.md>), [Docker AI Governance](<https://devfeed.tech/topics/docker-ai-governance.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [ai-agents](<https://devfeed.tech/tags/ai-agents.md>), [ai-governance](<https://devfeed.tech/tags/ai-governance.md>), [apparmor](<https://devfeed.tech/tags/apparmor.md>), [apt](<https://devfeed.tech/tags/apt.md>), [aws](<https://devfeed.tech/tags/aws.md>), [bash](<https://devfeed.tech/tags/bash.md>), [built-in](<https://devfeed.tech/tags/built-in.md>), [claude-code](<https://devfeed.tech/tags/claude-code.md>), [coding-agents](<https://devfeed.tech/tags/coding-agents.md>), [command](<https://devfeed.tech/tags/command.md>), [commands](<https://devfeed.tech/tags/commands.md>), [container](<https://devfeed.tech/tags/container.md>), [containers](<https://devfeed.tech/tags/containers.md>), [dev](<https://devfeed.tech/tags/dev.md>), [docker](<https://devfeed.tech/tags/docker.md>), [docker-container](<https://devfeed.tech/tags/docker-container.md>), [dockerfile](<https://devfeed.tech/tags/dockerfile.md>), [domains](<https://devfeed.tech/tags/domains.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [limits](<https://devfeed.tech/tags/limits.md>), [network](<https://devfeed.tech/tags/network.md>), [sandbox](<https://devfeed.tech/tags/sandbox.md>), [security](<https://devfeed.tech/tags/security.md>), [settings](<https://devfeed.tech/tags/settings.md>)

## AI overview

Claude Code's built-in sandbox is off by default and limits shell commands and their child processes, while file and web tools, hooks, and local MCP servers remain outside that boundary. Enable it with `/sandbox` or `sandbox.enabled`; configure filesystem write paths, network domains, and credential denials narrowly. On Linux and WSL2 it requires `bubblewrap` and `socat`; native Windows is unsupported. Managed settings can require the sandbox and block unsandboxed retries, though some list settings still merge across scopes. For unattended sessions using `--dangerously-skip-permissions`, a dev container contains more of the session, including tools and hooks. Its mounted workspace remains writable on the host, and readable credentials can still be exposed, so avoid mounting host secrets. The document's steps were checked against docs as of 2026-10-31 and specify Claude Code 2.1.307 or later.

## Source excerpt

Turn on Claude Code's Bash sandbox, set its file and network limits, or run the whole session in a dev container. Settings and commands from the docs.