openclaw sandbox
管理沙箱运行时,支持 Docker、SSH、OpenShell 三种后端。
命令概览
sandbox explain
查看当前生效的沙箱模式/scope/工作区访问策略及 tool policy:
openclaw sandbox explain
openclaw sandbox explain --session agent:main:main
openclaw sandbox explain --agent work
openclaw sandbox explain --jsonsandbox list
列出所有沙箱运行时及其状态:
openclaw sandbox list
openclaw sandbox list --browser # 仅列出浏览器容器
openclaw sandbox list --json输出字段:运行时名称、状态、后端类型、配置标签、创建时间、空闲时间、关联 session/agent。
sandbox recreate
强制删除旧运行时,下次使用时以当前配置重建:
openclaw sandbox recreate --all # 重建所有容器
openclaw sandbox recreate --session main # 指定 session
openclaw sandbox recreate --agent mybot # 指定 agent
openclaw sandbox recreate --browser # 仅浏览器容器
openclaw sandbox recreate --all --force # 跳过确认典型使用场景
更新 Docker 镜像后:
docker pull openclaw-sandbox:latest
docker tag openclaw-sandbox:latest openclaw-sandbox:bookworm-slim
openclaw sandbox recreate --all更改 SSH 目标或认证材料后:
# 修改 agents.defaults.sandbox.ssh.* 配置后
openclaw sandbox recreate --all更改 setupCommand 后:
openclaw sandbox recreate --agent <name>为什么需要 recreate
- 已有运行时继续使用旧配置运行
- 运行时在空闲 24h 后才自动清理
- 频繁使用的 agent 会无限期保留旧运行时
配置结构
{
"agents": {
"defaults": {
"sandbox": {
"mode": "all", // off | non-main | all
"backend": "docker", // docker | ssh | openshell
"scope": "agent", // session | agent | shared
"docker": {
"image": "openclaw-sandbox:bookworm-slim"
},
"prune": {
"idleHours": 24,
"maxAgeDays": 7
}
}
}
}
}Registry 迁移
旧版使用单体文件(~/.openclaw/sandbox/containers.json),新版使用分片目录。运行以下命令迁移:
openclaw doctor --fix相关链接
- cli-approvals — exec approvals 管理
- docs/gateway/sandboxing — 沙箱配置详解