@@ -9,16 +9,27 @@ read_when:
99
1010Docker is ** optional** . Use it only if you want a containerized gateway or to validate the Docker flow.
1111
12- ## Quick start (recommended)
12+ This guide covers:
13+ - Containerized Gateway (full Clawdis in Docker)
14+ - Per-session Agent Sandbox (host gateway + Docker-isolated agent tools)
1315
14- From the repo root:
16+ ## Requirements
17+
18+ - Docker Desktop (or Docker Engine) + Docker Compose v2
19+ - Enough disk for images + logs
20+
21+ ## Containerized Gateway (Docker Compose)
22+
23+ ### Quick start (recommended)
24+
25+ From repo root:
1526
1627``` bash
1728./docker-setup.sh
1829```
1930
2031This script:
21- - builds the image
32+ - builds the gateway image
2233- runs the onboarding wizard
2334- runs WhatsApp login
2435- starts the gateway via Docker Compose
@@ -27,7 +38,7 @@ It writes config/workspace on the host:
2738- ` ~/.clawdis/ `
2839- ` ~/clawd `
2940
30- ## Manual flow (compose)
41+ ### Manual flow (compose)
3142
3243``` bash
3344docker build -t clawdis:local -f Dockerfile .
@@ -36,14 +47,126 @@ docker compose run --rm clawdis-cli login
3647docker compose up -d clawdis-gateway
3748```
3849
39- ## E2E smoke test (Docker)
50+ ### Health check
51+
52+ ``` bash
53+ docker compose exec clawdis-gateway node dist/index.js health --token " $CLAWDIS_GATEWAY_TOKEN "
54+ ```
55+
56+ ### E2E smoke test (Docker)
4057
4158``` bash
4259scripts/e2e/onboard-docker.sh
4360```
4461
45- ## Notes
62+ ### Notes
4663
4764- Gateway bind defaults to ` lan ` for container use.
48- - Health check:
49- ` docker compose exec clawdis-gateway node dist/index.js health --token "$CLAWDIS_GATEWAY_TOKEN" `
65+ - The gateway container is the source of truth for sessions (` ~/.clawdis/sessions ` ).
66+
67+ ## Per-session Agent Sandbox (host gateway + Docker tools)
68+
69+ ### What it does
70+
71+ When ` agent.sandbox ` is enabled, ** non-main sessions** run tools inside a Docker
72+ container. The gateway stays on your host, but the tool execution is isolated:
73+ - one container per session (hard wall)
74+ - per-session workspace folder mounted at ` /workspace `
75+ - allow/deny tool policy (deny wins)
76+
77+ ### Default behavior
78+
79+ - Image: ` clawdis-sandbox:bookworm-slim `
80+ - One container per session
81+ - Workspace per session under ` ~/.clawdis/sandboxes `
82+ - Auto-prune: idle > 24h OR age > 7d
83+ - Default allow: ` bash ` , ` process ` , ` read ` , ` write ` , ` edit `
84+ - Default deny: ` browser ` , ` canvas ` , ` nodes ` , ` cron ` , ` discord ` , ` gateway `
85+
86+ ### Enable sandboxing
87+
88+ ``` json5
89+ {
90+ agent: {
91+ sandbox: {
92+ mode: " non-main" , // off | non-main | all
93+ perSession: true ,
94+ workspaceRoot: " ~/.clawdis/sandboxes" ,
95+ docker: {
96+ image: " clawdis-sandbox:bookworm-slim" ,
97+ workdir: " /workspace" ,
98+ readOnlyRoot: true ,
99+ tmpfs: [" /tmp" , " /var/tmp" , " /run" ],
100+ network: " bridge" ,
101+ user: " 1000:1000" ,
102+ capDrop: [" ALL" ],
103+ env: { LANG : " C.UTF-8" },
104+ setupCommand: " apt-get update && apt-get install -y git curl jq"
105+ },
106+ tools: {
107+ allow: [" bash" , " process" , " read" , " write" , " edit" ],
108+ deny: [" browser" , " canvas" , " nodes" , " cron" , " discord" , " gateway" ]
109+ },
110+ prune: {
111+ idleHours: 24 , // 0 disables idle pruning
112+ maxAgeDays: 7 // 0 disables max-age pruning
113+ }
114+ }
115+ }
116+ }
117+ ```
118+
119+ ### Build the default sandbox image
120+
121+ ``` bash
122+ scripts/sandbox-setup.sh
123+ ```
124+
125+ This builds ` clawdis-sandbox:bookworm-slim ` using ` Dockerfile.sandbox ` .
126+
127+ ### Custom sandbox image
128+
129+ Build your own image and point config to it:
130+
131+ ``` bash
132+ docker build -t my-clawdis-sbx -f Dockerfile.sandbox .
133+ ```
134+
135+ ``` json5
136+ {
137+ agent: {
138+ sandbox: { docker: { image: " my-clawdis-sbx" } }
139+ }
140+ }
141+ ```
142+
143+ ### Tool policy (allow/deny)
144+
145+ - ` deny ` wins over ` allow ` .
146+ - If ` allow ` is empty: all tools (except deny) are available.
147+ - If ` allow ` is non-empty: only tools in ` allow ` are available (minus deny).
148+
149+ ### Pruning strategy
150+
151+ Two knobs:
152+ - ` prune.idleHours ` : remove containers not used in X hours (0 = disable)
153+ - ` prune.maxAgeDays ` : remove containers older than X days (0 = disable)
154+
155+ Example:
156+ - Keep busy sessions but cap lifetime:
157+ ` idleHours: 24 ` , ` maxAgeDays: 7 `
158+ - Never prune:
159+ ` idleHours: 0 ` , ` maxAgeDays: 0 `
160+
161+ ### Security notes
162+
163+ - Hard wall only applies to ** tools** (bash/read/write/edit).
164+ - Host-only tools like browser/camera/canvas are blocked by default.
165+ - Allowing ` browser ` in sandbox ** breaks isolation** (browser runs on host).
166+
167+ ## Troubleshooting
168+
169+ - Image missing: build with ` scripts/sandbox-setup.sh ` or set ` agent.sandbox.docker.image ` .
170+ - Container not running: it will auto-create per session on demand.
171+ - Permission errors in sandbox: set ` docker.user ` to a UID: GID that matches your
172+ mounted workspace ownership (or chown the workspace folder).
0 commit comments