Experimenting with sandbox-runtime configuration for Claude Code on Linux.
- Enable sandbox per-project using
/sandboxcommand in Claude Code CLI - Allow Docker commands to run unsandboxed (so containers work)
- Allow sandboxed commands to communicate with Docker via
/var/run/docker.sock
# Check if installed
which srt
# If not, install : https://github.com/anthropic-experimental/sandbox-runtime/Add sandbox defaults that will be inherited when /sandbox is enabled per-project:
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": [],
"deny": []
},
"sandbox": {
"excludedCommands": ["docker", "docker-compose"],
"allowUnsandboxedCommands": true,
"network": {
"allowUnixSockets": ["/var/run/docker.sock"]
}
}
}Note: We intentionally omit enabled and autoAllowBashIfSandboxed here - these get added per-project by /sandbox.
Fine-grained control over what the sandbox allows:
{
"network": {
"allowedDomains": ["github.com", "*.github.com", "registry.npmjs.org"],
"deniedDomains": ["malicious.com"],
"allowUnixSockets": ["/var/run/docker.sock"],
"allowLocalBinding": false
},
"filesystem": {
"denyRead": ["~/.ssh"],
"allowWrite": [".", "/tmp"],
"denyWrite": [".env"]
},
"enableWeakerNestedSandbox": false
}In Claude Code CLI, type /sandbox to add to $PROJECT/.claude/settings.json:
{
"sandbox": {
"enabled": true,
"autoAllowBashIfSandboxed": true
}
}~/.claude/settings.json (global defaults)
+
.claude/settings.json (project overrides via /sandbox)
=
Final sandbox configuration
Experimental - Testing whether this configuration approach works as expected.