2026-01-10 20:28:34 +01:00
---
title: Sandbox CLI
summary: "Manage sandbox containers and inspect effective sandbox policy"
read_when: "You are managing sandbox containers or debugging sandbox/tool-policy behavior."
status: active
---
2026-01-09 09:40:46 +01:00
# Sandbox CLI
Manage Docker-based sandbox containers for isolated agent execution.
## Overview
2026-01-30 03:15:10 +01:00
OpenClaw can run agents in isolated Docker containers for security. The `sandbox` commands help you manage these containers, especially after updates or configuration changes.
2026-01-09 09:40:46 +01:00
## Commands
2026-01-30 03:15:10 +01:00
### `openclaw sandbox explain`
2026-01-10 20:28:34 +01:00
Inspect the **effective** sandbox mode/scope/workspace access, sandbox tool policy, and elevated gates (with fix-it config key paths).
```bash
2026-01-30 03:15:10 +01:00
openclaw sandbox explain
openclaw sandbox explain --session agent:main:main
openclaw sandbox explain --agent work
openclaw sandbox explain --json
2026-01-10 20:28:34 +01:00
```
2026-01-30 03:15:10 +01:00
### `openclaw sandbox list`
2026-01-09 09:40:46 +01:00
List all sandbox containers with their status and configuration.
```bash
2026-01-30 03:15:10 +01:00
openclaw sandbox list
openclaw sandbox list --browser # List only browser containers
openclaw sandbox list --json # JSON output
2026-01-09 09:40:46 +01:00
```
**Output includes:**
- Container name and status (running/stopped)
- Docker image and whether it matches config
- Age (time since creation)
- Idle time (time since last use)
- Associated session/agent
2026-01-30 03:15:10 +01:00
### `openclaw sandbox recreate`
2026-01-09 09:40:46 +01:00
Remove sandbox containers to force recreation with updated images/config.
```bash
2026-01-30 03:15:10 +01:00
openclaw sandbox recreate --all # Recreate all containers
openclaw sandbox recreate --session main # Specific session
openclaw sandbox recreate --agent mybot # Specific agent
openclaw sandbox recreate --browser # Only browser containers
openclaw sandbox recreate --all --force # Skip confirmation
2026-01-09 09:40:46 +01:00
```
**Options:**
- `--all` : Recreate all sandbox containers
- `--session <key>` : Recreate container for specific session
- `--agent <id>` : Recreate containers for specific agent
- `--browser` : Only recreate browser containers
- `--force` : Skip confirmation prompt
**Important:** Containers are automatically recreated when the agent is next used.
## Use Cases
### After updating Docker images
```bash
# Pull new image
2026-01-30 03:15:10 +01:00
docker pull openclaw-sandbox:latest
docker tag openclaw-sandbox:latest openclaw-sandbox:bookworm-slim
2026-01-09 09:40:46 +01:00
# Update config to use new image
2026-01-10 20:28:34 +01:00
# Edit config: agents.defaults.sandbox.docker.image (or agents.list[].sandbox.docker.image)
2026-01-09 09:40:46 +01:00
# Recreate containers
2026-01-30 03:15:10 +01:00
openclaw sandbox recreate --all
2026-01-09 09:40:46 +01:00
```
### After changing sandbox configuration
```bash
2026-01-10 20:28:34 +01:00
# Edit config: agents.defaults.sandbox.* (or agents.list[].sandbox.*)
2026-01-09 09:40:46 +01:00
# Recreate to apply new config
2026-01-30 03:15:10 +01:00
openclaw sandbox recreate --all
2026-01-09 09:40:46 +01:00
```
2026-01-19 01:35:17 +00:00
### After changing setupCommand
```bash
2026-01-30 03:15:10 +01:00
openclaw sandbox recreate --all
2026-01-19 01:35:17 +00:00
# or just one agent:
2026-01-30 03:15:10 +01:00
openclaw sandbox recreate --agent family
2026-01-19 01:35:17 +00:00
```
2026-01-09 09:40:46 +01:00
### For a specific agent only
```bash
# Update only one agent's containers
2026-01-30 03:15:10 +01:00
openclaw sandbox recreate --agent alfred
2026-01-09 09:40:46 +01:00
```
## Why is this needed?
**Problem:** When you update sandbox Docker images or configuration:
- Existing containers continue running with old settings
- Containers are only pruned after 24h of inactivity
- Regularly-used agents keep old containers running indefinitely
2026-01-30 03:15:10 +01:00
**Solution:** Use `openclaw sandbox recreate` to force removal of old containers. They'll be recreated automatically with current settings when next needed.
2026-01-09 09:40:46 +01:00
2026-01-30 03:15:10 +01:00
Tip: prefer `openclaw sandbox recreate` over manual `docker rm` . It uses the
2026-01-20 15:00:03 +00:00
Gateway’ s container naming and avoids mismatches when scope/session keys change.
2026-01-09 09:40:46 +01:00
## Configuration
2026-01-30 03:15:10 +01:00
Sandbox settings live in `~/.openclaw/openclaw.json` under `agents.defaults.sandbox` (per-agent overrides go in `agents.list[].sandbox` ):
2026-01-09 09:40:46 +01:00
```jsonc
{
2026-01-11 02:24:35 +00:00
"agents": {
"defaults": {
"sandbox": {
"mode": "all", // off, non-main, all
"scope": "agent", // session, agent, shared
"docker": {
2026-01-30 03:15:10 +01:00
"image": "openclaw-sandbox:bookworm-slim",
"containerPrefix": "openclaw-sbx-"
2026-01-11 02:24:35 +00:00
// ... more Docker options
},
"prune": {
"idleHours": 24, // Auto-prune after 24h idle
"maxAgeDays": 7 // Auto-prune after 7 days
}
2026-01-09 09:40:46 +01:00
}
}
}
}
```
## See Also
2026-01-09 13:52:00 +01:00
- [Sandbox Documentation ](/gateway/sandboxing )
- [Agent Configuration ](/concepts/agent-workspace )
- [Doctor Command ](/gateway/doctor ) - Check sandbox setup