#sandbox
1 messages · Page 1 of 1 (latest)
这个失败不是“配置文件语法错”,而是 OpenClaw 的沙箱安全校验直接拦截了容器 bind mount,所以 Agent 还没来得及回复就挂了。
1) 报错含义(为什么会失败)
报错关键信息:
bind mount
"/data/shared:/workspace/repo:rw"targets reserved container path"/workspace"
/workspace(以及 /agent)在 OpenClaw sandbox 里是保留挂载点:OpenClaw 会把 agent 的 workspace 挂到这里。
如果你再把东西挂到 /workspace/...,就可能把 OpenClaw 自己的挂载给遮住(shadow),所以默认直接禁止。
因此:不要把自定义 binds 的容器目标路径写到 /workspace 或 /agent 下面。
2) 正确的做法:挂到别的容器路径
把目标路径改成不冲突的,比如 /shared、/mnt/shared、/repo 这种(只要不是 /workspace/* 或 /agent/*):
{
id: "coder",
sandbox: {
mode: "all",
scope: "agent",
workspaceAccess: "rw",
docker: {
binds: ["/data/shared:/shared:rw"]
}
}
}
容器里就用 /shared 访问你主机的 /data/shared。
文档(中文):https://docs.openclaw.ai/zh-CN/gateway/sandboxing#自定义绑定挂载
3) 你接下来很可能还会遇到的第二个拦截(提前提醒)
就算你把目标路径改对了,source 是 /data/shared 这种“工作区之外”的目录,下一步可能会触发另一个安全限制:outside allowed roots。
安全/破窗开关是(谨慎用):
agents.*.sandbox.docker.dangerouslyAllowExternalBindSources: true
对应文档里也有列:dangerouslyAllowExternalBindSources / dangerouslyAllowReservedContainerTargets
(不建议开 dangerouslyAllowReservedContainerTargets,那就是允许你挂到 /workspace 这种保留路径上)
4) 改完配置后,记得重建沙箱容器
改配置后建议跑:
openclaw sandbox recreate --agent coder
不然可能还在用旧容器/旧挂载。
5) 为啥你日志里 bind 显示和你贴的配置不一致?
你贴的片段里是 "/data/shared:/repo:rw",但报错里是 "/data/shared:/workspace/repo:rw",说明 实际生效的配置里还有地方写了 :/workspace/...(可能是 defaults + agent 合并,或另一个 agent 配置)。
你可以在配置里全局搜一下 :/workspace(比如在 openclaw.json / agent 配置里)。
另外先把版本也发一下:openclaw --version(不同版本沙箱规则/默认 workdir 可能不一样)。
info [plugins] feishu_bitable: Registered bitable tools
14:56:22 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=main durationMs=74 error="Error: Sandbox security: bind mount "/data/shared:/shared/repo:rw" source "/data/shared" is outside allowed roots (/home/zhuli/.openclaw/workspace-reviewer). Use a dangerous override only when you fully trust this runtime."
14:56:22 error [diagnostic] lane task error: lane=main durationMs=74 error="Error: Sandbox security: bind mount "/data/shared:/shared/repo:rw" source "/data/shared" is outside allowed roots (/home/zhuli/.openclaw/workspace-reviewer). Use a dangerous override only when you fully trust this runtime."
14:56:22 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=session:agent:reviewer:feishu:group:oc_99733824abd7ed1dcf9a34816f9d76a1 durationMs=81 error="Error: Sandbox security: bind mount "/data/shared:/shared/repo:rw" source "/data/shared" is outside allowed roots (/home/zhuli/.openclaw/workspace-reviewer). Use a dangerous override only when you fully trust this runtime."
14:56:22 error [diagnostic] lane task error: lane=session:agent:reviewer:feishu:group:oc_99733824abd7ed1dcf9a34816f9d76a1 durationMs=81 error="Error: Sandbox security: bind mount "/data/shared:/shared/repo:rw" source "/data/shared" is outside allowed roots (/home/zhuli/.openclaw/workspace-reviewer). Use a dangerous override only when you fully trust this runtime."
你现在这个新报错已经从“目标路径冲突(/workspace)”变成了第二道沙箱安全校验:
source
"/data/shared"is outside allowed roots (/home/zhuli/.openclaw/workspace-reviewer)
意思是:OpenClaw 默认只允许把“工作区目录(workspace)及其相关目录”作为 bind mount 的来源。
像 /data/shared 这种工作区之外的路径,会被认为是“外部目录”,默认禁止(防止一条配置把整台机器的任意目录暴露进沙箱)。
而且你日志里是 agent=reviewer 的容器在报错(allowed roots 是 workspace-reviewer),说明你这个 bind 很可能是“全局默认 binds”或被合并到了 reviewer 上,而不只是 coder。
你有 3 种处理方式(按推荐程度)
A) 最推荐:不要额外 bind,把项目放进 agent 的 workspace
如果你只是想让沙箱访问代码/文件,直接把文件放到对应 agent 的 workspace 目录下即可(它本来就会挂到容器里):
workspace: "/home/zhuli/.openclaw/workspace-reviewer"(你日志里就是它)- 把需要的内容放到这个目录下面(或把 reviewer 的
workspace直接改成你想用的目录,比如/data/shared)
这样不需要 docker.binds,也不会触发外部目录限制。
B) 破窗方案:允许挂载工作区外目录(有风险)
如果你就是要把 /data/shared 挂进去,需要在对应 agent(或 defaults)里加:
sandbox: {
docker: {
binds: ["/data/shared:/shared:rw"],
dangerouslyAllowExternalBindSources: true
}
}
注意:这是“危险开关”,等于允许把工作区外的任意目录暴露进沙箱(按你写的 binds)。
相关配置键在安全文档里有列:
https://docs.openclaw.ai/gateway/security
C) 折中:在宿主机上把 /data/shared “挂”到 workspace 里面
比如用系统级的 bind mount(Linux 的 mount --bind / fstab)把 /data/shared 挂到:
/home/zhuli/.openclaw/workspace-reviewer/shared
这样从 OpenClaw 视角它就在 allowed roots 里面了,也不需要开危险开关。(这属于系统运维操作,看你环境是否方便做)
两个关键提醒
- 确认 binds 写在哪:如果你只想给
coder用,别写到agents.defaults.sandbox.docker.binds,不然会影响所有 agent(你现在 reviewer 就被影响了)。 - 改完配置后重建容器:
openclaw sandbox recreate --agent reviewer
# 或者
openclaw sandbox recreate --all
如果你把你实际的配置位置贴一下(openclaw.json 里 defaults 那段 + coder/reviewer 两个 agent 段落),我可以帮你指出到底是哪一条 bind 被合并到 reviewer 上导致它也炸了。
"agents": {
"defaults": {
"models": {
"moonshot/kimi-k2.5": {
"alias": "Kimi2.5"
}
},
"sandbox": {
"mode": "all",
"workspaceAccess": "rw",
"scope": "agent",
"docker": {
"image": "openclaw-sandbox-common:bookworm-slim",
"network": "bridge"
},
"browser": {
"enabled": true,
"image": "openclaw-sandbox-browser:bookworm-slim",
"network": "bridge"
}
}
},
"list": [
{
"id": "main",
"name": "main",
"workspace": "/home/zhuli/.openclaw/workspace",
"agentDir": "/home/zhuli/.openclaw/agents/main/agent"
},
{
"id": "coder",
"sandbox":{ "mode": "all",
"scope": "agent",
"workspaceAccess": "rw",
"docker": {
"binds": ["/data/shared:/shared:rw"]
}
},
"name": "coder",
"workspace": "/home/zhuli/.openclaw/workspace-coder",
"agentDir": "/home/zhuli/.openclaw/agents/coder/agent"
},
{
"id": "reviewer",
"sandbox":{ "mode": "all",
"scope": "agent",
"workspaceAccess": "rw",
"docker": {
"binds": ["/data/shared:/shared:rw"]
}
},
"name": "reviewer",
"workspace": "/home/zhuli/.openclaw/workspace-reviewer",
"agentDir": "/home/zhuli/.openclaw/agents/reviewer/agent", "model": { "primary": "Kimi2.5" }
},
{
"id": "architect",
"name": "architect",
"workspace": "/home/zhuli/.openclaw/workspace-architect",
"agentDir": "/home/zhuli/.openclaw/agents/architect/agent", "model": { "primary": "Kimi2.5" }
}
]
},详细配置
哪里有问题呢?
问题点其实就两个(你日志里两个报错分别对应它们):
1) 你把 bind 的容器目标路径挂到了 /workspace/...(保留路径)
日志里这句:
bind mount "/data/shared:/workspace/repo:rw" targets reserved container path "/workspace"
说明实际生效的某条 bind 是 :/workspace/repo(不是你贴的 :/repo)。
/workspace 在 sandbox 里是 OpenClaw 自己挂载 workspace 用的,禁止你再往里面挂(会把它遮住)。
修复:把目标路径换成不在 /workspace、/agent 下面的,比如 /shared:
- ✅
"/data/shared:/shared:rw" - ❌
"/data/shared:/workspace/repo:rw"
以及:改完后跑一次 openclaw sandbox recreate --agent coder,否则旧容器/旧配置可能还在。
2) 你 bind 的主机源路径是 /data/shared,它在 allowed roots 之外
你后面的新报错就是这个:
source "/data/shared" is outside allowed roots (/home/zhuli/.openclaw/workspace-reviewer)
OpenClaw 默认只允许 bind 来源在 agent workspace 根目录(例如 /home/zhuli/.openclaw/workspace-xxx)内的路径;/data/shared 属于外部路径,会被拦截。
三选一修复:
- 最推荐:把需要的文件放进该 agent 的
workspace目录(它本来就会被挂进沙箱),就不需要额外 binds - 或者把该 agent 的
workspace直接改成/data/shared(让它变成 allowed root) - 或破窗:在该 agent 配置里加
sandbox.docker.dangerouslyAllowExternalBindSources: true(有风险)
为什么你贴的配置是 :/repo,日志却是 :/workspace/repo?
这通常是:
- 你在 别的地方(比如
agents.defaults.sandbox.docker.binds)还配了一条:/workspace/...(合并后生效)
- 或者改了配置但没 recreate sandbox 容器,日志还是旧的/容器还是旧的
想一眼看清“到底生效了哪些 binds”,跑:
openclaw sandbox explain --agent coder
openclaw sandbox explain --agent reviewer
你把 openclaw sandbox explain --agent coder 的输出贴出来,我就能准确指出是哪一条 bind 在把 /workspace 或 /data/shared 搞炸。
我需要多agent来开发代码review,那么怎么配置u7yyyyyyyyyyyyyyyyyyyy66666666666666666666666666666666666666666666 c nm33v+/+