Gateway
การแซนด์บ็อกซ์
OpenClaw สามารถเรียกใช้ tools ภายใน sandbox backends เพื่อลดขอบเขตผลกระทบได้ การทำเช่นนี้เป็น ตัวเลือก และควบคุมด้วยการกำหนดค่า (agents.defaults.sandbox หรือ agents.list[].sandbox) หากปิด sandboxing ไว้ tools จะทำงานบน host ส่วน Gateway ยังคงอยู่บน host; การเรียกใช้ tool จะทำงานใน sandbox ที่แยกออกมาเมื่อเปิดใช้งาน
สิ่งที่จะถูก sandbox
- การเรียกใช้ tool (
exec,read,write,edit,apply_patch,processฯลฯ) - เบราว์เซอร์แบบ sandbox ที่เป็นตัวเลือก (
agents.defaults.sandbox.browser)
รายละเอียดเบราว์เซอร์แบบ sandbox
- โดยค่าเริ่มต้น เบราว์เซอร์แบบ sandbox จะเริ่มทำงานอัตโนมัติ (เพื่อให้แน่ใจว่า CDP เข้าถึงได้) เมื่อ browser tool ต้องใช้ กำหนดค่าผ่าน
agents.defaults.sandbox.browser.autoStartและagents.defaults.sandbox.browser.autoStartTimeoutMs - โดยค่าเริ่มต้น container ของเบราว์เซอร์แบบ sandbox ใช้ Docker network เฉพาะ (
openclaw-sandbox-browser) แทน networkbridgeแบบ global กำหนดค่าด้วยagents.defaults.sandbox.browser.network agents.defaults.sandbox.browser.cdpSourceRangeที่เป็นตัวเลือกจะจำกัด CDP ingress ที่ขอบ container ด้วย CIDR allowlist (เช่น172.21.0.1/32)- การเข้าถึงตัวสังเกตการณ์ noVNC มีการป้องกันด้วยรหัสผ่านโดยค่าเริ่มต้น; OpenClaw จะออก token URL อายุสั้นที่ให้บริการหน้า bootstrap แบบ local และเปิด noVNC พร้อมรหัสผ่านใน URL fragment (ไม่ใช่ใน query/header logs)
agents.defaults.sandbox.browser.allowHostControlอนุญาตให้ session แบบ sandbox กำหนดเป้าหมายไปยังเบราว์เซอร์ของ host ได้อย่างชัดเจน- allowlist ที่เป็นตัวเลือกควบคุม
target: "custom":allowedControlUrls,allowedControlHosts,allowedControlPorts
ไม่ถูก sandbox:
- process ของ Gateway เอง
- tool ใด ๆ ที่อนุญาตอย่างชัดเจนให้ทำงานนอก sandbox (เช่น
tools.elevated)- Elevated exec จะข้าม sandboxing และใช้ escape path ที่กำหนดค่าไว้ (
gatewayโดยค่าเริ่มต้น หรือnodeเมื่อ exec target คือnode) - หากปิด sandboxing ไว้
tools.elevatedจะไม่เปลี่ยนการเรียกใช้ (ทำงานบน host อยู่แล้ว) ดู Elevated Mode
- Elevated exec จะข้าม sandboxing และใช้ escape path ที่กำหนดค่าไว้ (
โหมด
agents.defaults.sandbox.mode ควบคุมว่า sandboxing จะถูกใช้ เมื่อใด:
off
ไม่มี sandboxing
non-main
sandbox เฉพาะ session ที่ ไม่ใช่ main (ค่าเริ่มต้นหากคุณต้องการให้แชทปกติอยู่บน host)
"non-main" อิงตาม session.mainKey (ค่าเริ่มต้น "main") ไม่ใช่ agent id session แบบกลุ่ม/channel ใช้ key ของตัวเอง จึงนับเป็น non-main และจะถูก sandbox
all
ทุก session ทำงานใน sandbox
ขอบเขต
agents.defaults.sandbox.scope ควบคุมว่า จะสร้าง container กี่ตัว:
"agent"(ค่าเริ่มต้น): หนึ่ง container ต่อ agent"session": หนึ่ง container ต่อ session"shared": หนึ่ง container ที่ใช้ร่วมกันโดย session แบบ sandbox ทั้งหมด
Backend
agents.defaults.sandbox.backend ควบคุมว่า runtime ใด จะให้ sandbox:
"docker"(ค่าเริ่มต้นเมื่อเปิดใช้งาน sandboxing): sandbox runtime แบบ local ที่รองรับด้วย Docker"ssh": sandbox runtime ระยะไกลทั่วไปที่รองรับด้วย SSH"openshell": sandbox runtime ที่รองรับด้วย OpenShell
การกำหนดค่าเฉพาะ SSH อยู่ภายใต้ agents.defaults.sandbox.ssh การกำหนดค่าเฉพาะ OpenShell อยู่ภายใต้ plugins.entries.openshell.config
การเลือก backend
| Docker | SSH | OpenShell | |
|---|---|---|---|
| ตำแหน่งที่ทำงาน | Local container | host ใด ๆ ที่เข้าถึงผ่าน SSH ได้ | sandbox ที่จัดการโดย OpenShell |
| การตั้งค่า | scripts/sandbox-setup.sh |
SSH key + target host | เปิดใช้งาน OpenShell plugin |
| โมเดล workspace | Bind-mount หรือ copy | Remote-canonical (seed ครั้งเดียว) | mirror หรือ remote |
| การควบคุม network | docker.network (ค่าเริ่มต้น: none) |
ขึ้นอยู่กับ remote host | ขึ้นอยู่กับ OpenShell |
| Browser sandbox | รองรับ | ไม่รองรับ | ยังไม่รองรับ |
| Bind mounts | docker.binds |
N/A | N/A |
| เหมาะที่สุดสำหรับ | การพัฒนาแบบ local, การแยกเต็มรูปแบบ | การ offload ไปยังเครื่องระยะไกล | sandbox ระยะไกลที่จัดการให้พร้อมการ sync สองทางแบบเลือกได้ |
Docker backend
sandboxing ปิดอยู่โดยค่าเริ่มต้น หากคุณเปิดใช้งาน sandboxing และไม่ได้เลือก backend OpenClaw จะใช้ Docker backend โดยจะเรียกใช้ tools และเบราว์เซอร์แบบ sandbox ในเครื่องผ่าน Docker daemon socket (/var/run/docker.sock) การแยก sandbox container ถูกกำหนดโดย Docker namespaces
หากต้องการเปิดเผย host GPUs ให้ Docker sandboxes ให้ตั้งค่า agents.defaults.sandbox.docker.gpus หรือ override ราย agent agents.list[].sandbox.docker.gpus ค่านี้จะถูกส่งไปยัง flag --gpus ของ Docker เป็น argument แยกต่างหาก เช่น "all" หรือ "device=GPU-uuid" และต้องมี host runtime ที่เข้ากันได้ เช่น NVIDIA Container Toolkit
SSH backend
ใช้ backend: "ssh" เมื่อคุณต้องการให้ OpenClaw sandbox exec, file tools และการอ่านสื่อบนเครื่องใด ๆ ที่เข้าถึงผ่าน SSH ได้
{
agents: {
defaults: {
sandbox: {
mode: "all",
backend: "ssh",
scope: "session",
workspaceAccess: "rw",
ssh: {
target: "user@gateway-host:22",
workspaceRoot: "/tmp/openclaw-sandboxes",
strictHostKeyChecking: true,
updateHostKeys: true,
identityFile: "~/.ssh/id_ed25519",
certificateFile: "~/.ssh/id_ed25519-cert.pub",
knownHostsFile: "~/.ssh/known_hosts",
// Or use SecretRefs / inline contents instead of local files:
// identityData: { source: "env", provider: "default", id: "SSH_IDENTITY" },
// certificateData: { source: "env", provider: "default", id: "SSH_CERTIFICATE" },
// knownHostsData: { source: "env", provider: "default", id: "SSH_KNOWN_HOSTS" },
},
},
},
},
}
วิธีการทำงาน
- OpenClaw สร้าง remote root ต่อ scope ภายใต้
sandbox.ssh.workspaceRoot - เมื่อใช้งานครั้งแรกหลังจากสร้างหรือสร้างใหม่ OpenClaw จะ seed remote workspace นั้นจาก local workspace หนึ่งครั้ง
- หลังจากนั้น
exec,read,write,edit,apply_patch, การอ่าน prompt media และ inbound media staging จะทำงานกับ remote workspace โดยตรงผ่าน SSH - OpenClaw จะไม่ sync การเปลี่ยนแปลงระยะไกลกลับมายัง local workspace โดยอัตโนมัติ
ข้อมูล authentication
identityFile,certificateFile,knownHostsFile: ใช้ไฟล์ local ที่มีอยู่และส่งผ่าน config ของ OpenSSHidentityData,certificateData,knownHostsData: ใช้ inline strings หรือ SecretRefs OpenClaw จะแปลงค่าผ่าน snapshot ของ secrets runtime ปกติ เขียนลง temp files ด้วย0600และลบทิ้งเมื่อ session SSH สิ้นสุด- หากตั้งค่าทั้ง
*Fileและ*Dataสำหรับรายการเดียวกัน*Dataจะมีผลสำหรับ session SSH นั้น
ผลของ remote-canonical
นี่คือโมเดล remote-canonical remote SSH workspace จะกลายเป็นสถานะ sandbox จริงหลังจาก seed เริ่มต้น
- การแก้ไขแบบ host-local ที่ทำนอก OpenClaw หลังขั้นตอน seed จะมองไม่เห็นจากระยะไกลจนกว่าคุณจะสร้าง sandbox ใหม่
openclaw sandbox recreateจะลบ remote root ต่อ scope และ seed ใหม่จาก local ในการใช้งานครั้งถัดไป- ไม่รองรับ browser sandboxing บน SSH backend
- การตั้งค่า
sandbox.docker.*ไม่มีผลกับ SSH backend
OpenShell backend
ใช้ backend: "openshell" เมื่อคุณต้องการให้ OpenClaw sandbox tools ในสภาพแวดล้อมระยะไกลที่จัดการโดย OpenShell สำหรับคู่มือการตั้งค่าแบบเต็ม ข้อมูลอ้างอิงการกำหนดค่า และการเปรียบเทียบโหมด workspace โปรดดู หน้า OpenShell เฉพาะ
OpenShell ใช้ core SSH transport และ remote filesystem bridge เดียวกับ SSH backend ทั่วไปซ้ำ และเพิ่ม lifecycle เฉพาะ OpenShell (sandbox create/get/delete, sandbox ssh-config) พร้อมโหมด workspace mirror ที่เป็นตัวเลือก
{
agents: {
defaults: {
sandbox: {
mode: "all",
backend: "openshell",
scope: "session",
workspaceAccess: "rw",
},
},
},
plugins: {
entries: {
openshell: {
enabled: true,
config: {
from: "openclaw",
mode: "remote", // mirror | remote
remoteWorkspaceDir: "/sandbox",
remoteAgentWorkspaceDir: "/agent",
},
},
},
},
}
โหมด OpenShell:
mirror(ค่าเริ่มต้น): local workspace ยังคงเป็น canonical OpenClaw sync ไฟล์ local เข้า OpenShell ก่อน exec และ sync remote workspace กลับหลัง execremote: OpenShell workspace เป็น canonical หลังจากสร้าง sandbox แล้ว OpenClaw seed remote workspace หนึ่งครั้งจาก local workspace จากนั้น file tools และ exec จะทำงานกับ remote sandbox โดยตรงโดยไม่ sync การเปลี่ยนแปลงกลับ
รายละเอียด remote transport
- OpenClaw ขอ config SSH เฉพาะ sandbox จาก OpenShell ผ่าน
openshell sandbox ssh-config <name> - Core เขียน config SSH นั้นลง temp file, เปิด session SSH และใช้ remote filesystem bridge เดียวกับที่ใช้โดย
backend: "ssh"ซ้ำ - ในโหมด
mirrorมีเพียง lifecycle เท่านั้นที่ต่างกัน: sync local ไป remote ก่อน exec แล้ว sync กลับหลัง exec
ข้อจำกัดปัจจุบันของ OpenShell
- ยังไม่รองรับ sandbox browser
- ไม่รองรับ
sandbox.docker.bindsบน OpenShell backend - runtime knobs เฉพาะ Docker ภายใต้
sandbox.docker.*ยังคงมีผลเฉพาะกับ Docker backend เท่านั้น
โหมด workspace
OpenShell มีโมเดล workspace สองแบบ ส่วนนี้คือส่วนที่สำคัญที่สุดในการใช้งานจริง
mirror (local canonical)
ใช้ plugins.entries.openshell.config.mode: "mirror" เมื่อคุณต้องการให้ local workspace ยังคงเป็น canonical
พฤติกรรม:
- ก่อน
execOpenClaw sync local workspace เข้าไปยัง OpenShell sandbox - หลัง
execOpenClaw sync remote workspace กลับมายัง local workspace - File tools ยังคงทำงานผ่าน sandbox bridge แต่ local workspace ยังคงเป็น source of truth ระหว่างรอบ
ใช้สิ่งนี้เมื่อ:
- คุณแก้ไขไฟล์ภายในเครื่องนอก OpenClaw และต้องการให้การเปลี่ยนแปลงเหล่านั้นปรากฏใน sandbox โดยอัตโนมัติ
- คุณต้องการให้ OpenShell sandbox ทำงานใกล้เคียงกับแบ็กเอนด์ Docker มากที่สุด
- คุณต้องการให้ workspace ของโฮสต์สะท้อนการเขียนจาก sandbox หลังแต่ละรอบ exec
ข้อแลกเปลี่ยน: มีต้นทุนการซิงก์เพิ่มเติมก่อนและหลัง exec
remote (OpenShell canonical)
ใช้ plugins.entries.openshell.config.mode: "remote" เมื่อคุณต้องการให้ OpenShell workspace กลายเป็นแหล่งอ้างอิงหลัก
พฤติกรรม:
- เมื่อสร้าง sandbox ครั้งแรก OpenClaw จะตั้งต้น remote workspace จาก local workspace หนึ่งครั้ง
- หลังจากนั้น
exec,read,write,editและapply_patchจะทำงานกับ remote OpenShell workspace โดยตรง - OpenClaw จะ ไม่ ซิงก์การเปลี่ยนแปลงระยะไกลกลับเข้า local workspace หลัง exec
- การอ่านสื่อในช่วง prompt ยังทำงานได้ เพราะเครื่องมือไฟล์และสื่ออ่านผ่าน sandbox bridge แทนที่จะสมมติว่าเป็นพาธโฮสต์ภายในเครื่อง
- การส่งข้อมูลใช้ SSH เข้าไปยัง OpenShell sandbox ที่ได้จาก
openshell sandbox ssh-config
ผลลัพธ์สำคัญ:
- หากคุณแก้ไขไฟล์บนโฮสต์นอก OpenClaw หลังขั้นตอนตั้งต้น remote sandbox จะ ไม่ เห็นการเปลี่ยนแปลงเหล่านั้นโดยอัตโนมัติ
- หากสร้าง sandbox ใหม่ remote workspace จะถูกตั้งต้นจาก local workspace อีกครั้ง
- เมื่อใช้
scope: "agent"หรือscope: "shared"remote workspace นั้นจะถูกแชร์ในขอบเขตเดียวกัน
ใช้สิ่งนี้เมื่อ:
- sandbox ควรอยู่ฝั่ง OpenShell ระยะไกลเป็นหลัก
- คุณต้องการลดค่าใช้จ่ายในการซิงก์ต่อรอบ
- คุณไม่ต้องการให้การแก้ไขภายในเครื่องของโฮสต์เขียนทับสถานะ remote sandbox อย่างเงียบ ๆ
เลือก mirror หากคุณมอง sandbox เป็นสภาพแวดล้อมชั่วคราวสำหรับการดำเนินการ เลือก remote หากคุณมอง sandbox เป็น workspace จริง
วงจรชีวิตของ OpenShell
OpenShell sandboxes ยังคงถูกจัดการผ่านวงจรชีวิต sandbox ปกติ:
openclaw sandbox listแสดง runtime ของ OpenShell รวมถึง runtime ของ Dockeropenclaw sandbox recreateลบ runtime ปัจจุบันและให้ OpenClaw สร้างใหม่เมื่อใช้งานครั้งถัดไป- ตรรกะการ prune ก็รับรู้แบ็กเอนด์เช่นกัน
สำหรับโหมด remote การสร้างใหม่มีความสำคัญเป็นพิเศษ:
- การสร้างใหม่จะลบ canonical remote workspace สำหรับ scope นั้น
- การใช้งานครั้งถัดไปจะตั้งต้น remote workspace ใหม่จาก local workspace
สำหรับโหมด mirror การสร้างใหม่ส่วนใหญ่จะรีเซ็ตสภาพแวดล้อมดำเนินการระยะไกล เพราะ local workspace ยังคงเป็นแหล่งอ้างอิงหลักอยู่แล้ว
การเข้าถึง workspace
agents.defaults.sandbox.workspaceAccess ควบคุมว่า sandbox มองเห็นอะไรได้บ้าง:
none (default)
เครื่องมือจะเห็น sandbox workspace ใต้ ~/.openclaw/sandboxes
ro
เมานต์ agent workspace แบบอ่านอย่างเดียวที่ /agent (ปิดใช้งาน write/edit/apply_patch)
rw
เมานต์ agent workspace แบบอ่าน/เขียนที่ /workspace
เมื่อใช้แบ็กเอนด์ OpenShell:
- โหมด
mirrorยังคงใช้ local workspace เป็นแหล่งอ้างอิงหลักระหว่างรอบ exec - โหมด
remoteใช้ remote OpenShell workspace เป็นแหล่งอ้างอิงหลักหลังการตั้งต้นครั้งแรก workspaceAccess: "ro"และ"none"ยังคงจำกัดพฤติกรรมการเขียนในแบบเดียวกัน
สื่อขาเข้าจะถูกคัดลอกเข้า active sandbox workspace (media/inbound/*)
bind mounts แบบกำหนดเอง
agents.defaults.sandbox.docker.binds เมานต์ไดเรกทอรีโฮสต์เพิ่มเติมเข้าไปในคอนเทนเนอร์ รูปแบบ: host:container:mode (เช่น "/home/user/source:/source:rw")
binds แบบส่วนกลางและต่อ agent จะถูก ผสาน กัน (ไม่ใช่แทนที่กัน) ภายใต้ scope: "shared" binds ต่อ agent จะถูกละเว้น
agents.defaults.sandbox.browser.binds เมานต์ไดเรกทอรีโฮสต์เพิ่มเติมเข้าไปในคอนเทนเนอร์ sandbox browser เท่านั้น
- เมื่อตั้งค่าไว้ (รวมถึง
[]) ค่านี้จะแทนที่agents.defaults.sandbox.docker.bindsสำหรับคอนเทนเนอร์ browser - เมื่อไม่ระบุ คอนเทนเนอร์ browser จะ fallback ไปใช้
agents.defaults.sandbox.docker.binds(เข้ากันได้ย้อนหลัง)
ตัวอย่าง (ซอร์สแบบอ่านอย่างเดียว + ไดเรกทอรีข้อมูลเพิ่มเติม):
{
agents: {
defaults: {
sandbox: {
docker: {
binds: ["/home/user/source:/source:ro", "/var/data/myapp:/data:ro"],
},
},
},
list: [
{
id: "build",
sandbox: {
docker: {
binds: ["/mnt/cache:/cache:rw"],
},
},
},
],
},
}
อิมเมจและการตั้งค่า
อิมเมจ Docker เริ่มต้น: openclaw-sandbox:bookworm-slim
Build the default image
จาก source checkout:
scripts/sandbox-setup.sh
จากการติดตั้ง npm (ไม่จำเป็นต้องมี source checkout):
docker build -t openclaw-sandbox:bookworm-slim - <<'DOCKERFILE'
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
bash ca-certificates curl git jq python3 ripgrep \
&& rm -rf /var/lib/apt/lists/*
RUN useradd --create-home --shell /bin/bash sandbox
USER sandbox
WORKDIR /home/sandbox
CMD ["sleep", "infinity"]
DOCKERFILE
อิมเมจเริ่มต้น ไม่มี Node หาก skill ต้องใช้ Node (หรือ runtime อื่น) ให้ bake อิมเมจแบบกำหนดเอง หรือ install ผ่าน sandbox.docker.setupCommand (ต้องมี network egress + root ที่เขียนได้ + root user)
OpenClaw จะไม่แทนที่ด้วย debian:bookworm-slim ธรรมดาแบบเงียบ ๆ เมื่อไม่มี openclaw-sandbox:bookworm-slim การรัน sandbox ที่ target อิมเมจเริ่มต้นจะ fail fast พร้อมคำแนะนำการ build จนกว่าคุณจะ build เพราะอิมเมจที่มาพร้อมระบบมี python3 สำหรับตัวช่วยเขียน/แก้ไขของ sandbox
Optional: build the common image
สำหรับอิมเมจ sandbox ที่ใช้งานได้มากขึ้นพร้อมเครื่องมือทั่วไป (ตัวอย่างเช่น curl, jq, nodejs, python3, git):
จาก source checkout:
scripts/sandbox-common-setup.sh
จากการติดตั้ง npm ให้ build อิมเมจเริ่มต้นก่อน (ดูด้านบน) จากนั้น build อิมเมจ common ต่อบนอิมเมจนั้นโดยใช้ scripts/docker/sandbox/Dockerfile.common จาก repository
จากนั้นตั้งค่า agents.defaults.sandbox.docker.image เป็น openclaw-sandbox-common:bookworm-slim
Optional: build the sandbox browser image
จาก source checkout:
scripts/sandbox-browser-setup.sh
จากการติดตั้ง npm ให้ build โดยใช้ scripts/docker/sandbox/Dockerfile.browser จาก repository
โดยค่าเริ่มต้น คอนเทนเนอร์ Docker sandbox จะรันแบบ ไม่มีเครือข่าย Override ด้วย agents.defaults.sandbox.docker.network
Sandbox browser Chromium defaults
อิมเมจ sandbox browser ที่มาพร้อมระบบยังใช้ค่าเริ่มต้นการเริ่มต้น Chromium แบบระมัดระวังสำหรับงานที่รันในคอนเทนเนอร์ ค่าเริ่มต้นของคอนเทนเนอร์ปัจจุบันรวมถึง:
--remote-debugging-address=127.0.0.1--remote-debugging-port=<derived from OPENCLAW_BROWSER_CDP_PORT>--user-data-dir=${HOME}/.chrome--no-first-run--no-default-browser-check--disable-3d-apis--disable-gpu--disable-dev-shm-usage--disable-background-networking--disable-extensions--disable-features=TranslateUI--disable-breakpad--disable-crash-reporter--disable-software-rasterizer--no-zygote--metrics-recording-only--renderer-process-limit=2--no-sandboxเมื่อเปิดใช้noSandbox- แฟล็ก hardening ด้านกราฟิกสามรายการ (
--disable-3d-apis,--disable-software-rasterizer,--disable-gpu) เป็นตัวเลือกและมีประโยชน์เมื่อคอนเทนเนอร์ไม่มีการรองรับ GPU ตั้งค่าOPENCLAW_BROWSER_DISABLE_GRAPHICS_FLAGS=0หาก workload ของคุณต้องใช้ WebGL หรือฟีเจอร์ 3D/browser อื่น --disable-extensionsเปิดใช้เป็นค่าเริ่มต้น และสามารถปิดได้ด้วยOPENCLAW_BROWSER_DISABLE_EXTENSIONS=0สำหรับ flow ที่พึ่งพา extension--renderer-process-limit=2ถูกควบคุมโดยOPENCLAW_BROWSER_RENDERER_PROCESS_LIMIT=<N>โดย0จะคงค่าเริ่มต้นของ Chromium
หากคุณต้องการโปรไฟล์ runtime ที่ต่างออกไป ให้ใช้อิมเมจ browser แบบกำหนดเองและระบุ entrypoint ของคุณเอง สำหรับโปรไฟล์ Chromium ภายในเครื่อง (ไม่ใช่คอนเทนเนอร์) ให้ใช้ browser.extraArgs เพื่อเพิ่มแฟล็กเริ่มต้นเพิ่มเติม
Network security defaults
network: "host"ถูกบล็อกnetwork: "container:<id>"ถูกบล็อกโดยค่าเริ่มต้น (ความเสี่ยงจากการ bypass namespace join)- การ override แบบ break-glass:
agents.defaults.sandbox.docker.dangerouslyAllowContainerNamespaceJoin: true
การติดตั้ง Docker และ containerized Gateway อยู่ที่นี่: Docker
สำหรับการปรับใช้ Docker Gateway, scripts/docker/setup.sh สามารถ bootstrap การกำหนดค่า sandbox ได้ ตั้งค่า OPENCLAW_SANDBOX=1 (หรือ true/yes/on) เพื่อเปิดใช้เส้นทางนั้น คุณสามารถ override ตำแหน่ง socket ด้วย OPENCLAW_DOCKER_SOCKET ข้อมูลอ้างอิงการตั้งค่าและ env แบบเต็ม: Docker
setupCommand (การตั้งค่าคอนเทนเนอร์ครั้งเดียว)
setupCommand รัน ครั้งเดียว หลังจากสร้างคอนเทนเนอร์ sandbox แล้ว (ไม่ใช่ทุกรัน) มันทำงานภายในคอนเทนเนอร์ผ่าน sh -lc
พาธ:
- ส่วนกลาง:
agents.defaults.sandbox.docker.setupCommand - ต่อ agent:
agents.list[].sandbox.docker.setupCommand
ข้อผิดพลาดที่พบบ่อย
- ค่าเริ่มต้นของ
docker.networkคือ"none"(ไม่มี egress) ดังนั้นการติดตั้งแพ็กเกจจะล้มเหลว docker.network: "container:<id>"ต้องใช้dangerouslyAllowContainerNamespaceJoin: trueและใช้เฉพาะกรณีฉุกเฉินเท่านั้นreadOnlyRoot: trueจะป้องกันการเขียน; ตั้งค่าreadOnlyRoot: falseหรือสร้างอิมเมจแบบกำหนดเองไว้ล่วงหน้าuserต้องเป็น root สำหรับการติดตั้งแพ็กเกจ (ละเว้นuserหรือตั้งค่าuser: "0:0")- Sandbox exec ไม่ สืบทอด
process.envจากโฮสต์ ใช้agents.defaults.sandbox.docker.env(หรืออิมเมจแบบกำหนดเอง) สำหรับคีย์ API ของ skill
นโยบายเครื่องมือและทางออกฉุกเฉิน
นโยบายอนุญาต/ปฏิเสธเครื่องมือยังคงมีผลก่อนกฎ sandbox หากเครื่องมือถูกปฏิเสธในระดับทั่วโลกหรือต่อ agent การใช้ sandbox จะไม่นำเครื่องมือนั้นกลับมา
tools.elevated คือทางออกฉุกเฉินแบบชัดเจนที่รัน exec นอก sandbox (gateway ตามค่าเริ่มต้น หรือ node เมื่อเป้าหมาย exec คือ node) directive /exec มีผลเฉพาะกับผู้ส่งที่ได้รับอนุญาตและคงอยู่ต่อ session; หากต้องการปิดใช้งาน exec แบบเด็ดขาด ให้ใช้นโยบายเครื่องมือแบบปฏิเสธ (ดู Sandbox เทียบกับนโยบายเครื่องมือเทียบกับ Elevated)
การดีบัก:
- ใช้
openclaw sandbox explainเพื่อตรวจสอบโหมด sandbox ที่มีผลจริง นโยบายเครื่องมือ และคีย์ config สำหรับการแก้ไข - ดู Sandbox เทียบกับนโยบายเครื่องมือเทียบกับ Elevated สำหรับกรอบคิดเรื่อง "ทำไมสิ่งนี้ถึงถูกบล็อก?"
ล็อกให้แน่นหนาไว้
การ override แบบหลาย agent
แต่ละ agent สามารถ override sandbox + เครื่องมือได้: agents.list[].sandbox และ agents.list[].tools (รวมถึง agents.list[].tools.sandbox.tools สำหรับนโยบายเครื่องมือของ sandbox) ดู Sandbox และเครื่องมือแบบหลาย Agent สำหรับลำดับความสำคัญ
ตัวอย่างการเปิดใช้งานขั้นต่ำ
{
agents: {
defaults: {
sandbox: {
mode: "non-main",
scope: "session",
workspaceAccess: "none",
},
},
},
}
ที่เกี่ยวข้อง
- Sandbox และเครื่องมือแบบหลาย Agent — การ override ต่อ agent และลำดับความสำคัญ
- OpenShell — การตั้งค่า backend sandbox ที่จัดการให้ โหมด workspace และข้อมูลอ้างอิง config
- การกำหนดค่า Sandbox
- Sandbox เทียบกับนโยบายเครื่องมือเทียบกับ Elevated — การดีบัก "ทำไมสิ่งนี้ถึงถูกบล็อก?"
- ความปลอดภัย