Docker is optional. Use it only if you want a containerized gateway or to validate the Docker flow.
This guide covers:
Sandboxing details: Sandboxing
From repo root:
./docker-setup.sh
This script:
.envOptional env vars:
CODERCLAW_DOCKER_APT_PACKAGES — install extra apt packages during buildCODERCLAW_EXTRA_MOUNTS — add extra host bind mountsCODERCLAW_HOME_VOLUME — persist /home/node in a named volumeAfter it finishes:
http://127.0.0.1:18789/ in your browser.docker compose run --rm coderclaw-cli dashboard --no-open.It writes config/workspace on the host:
~/.coderclaw/~/.coderclaw/workspaceRunning on a VPS? See Hetzner (Docker VPS).
For easier day-to-day Docker management, install ClawDock:
mkdir -p ~/.clawdock && curl -sL https://raw.githubusercontent.com/SeanHogg/coderClaw/main/scripts/shell-helpers/clawdock-helpers.sh -o ~/.clawdock/clawdock-helpers.sh
Add to your shell config (zsh):
echo 'source ~/.clawdock/clawdock-helpers.sh' >> ~/.zshrc && source ~/.zshrc
Then use clawdock-start, clawdock-stop, clawdock-dashboard, etc. Run clawdock-help for all commands.
See ClawDock Helper README for details.
docker build -t coderclaw:local -f Dockerfile .
docker compose run --rm coderclaw-cli onboard
docker compose up -d coderclaw-gateway
Note: run docker compose ... from the repo root. If you enabled
CODERCLAW_EXTRA_MOUNTS or CODERCLAW_HOME_VOLUME, the setup script writes
docker-compose.extra.yml; include it when running Compose elsewhere:
docker compose -f docker-compose.yml -f docker-compose.extra.yml <command>
If you see “unauthorized” or “disconnected (1008): pairing required”, fetch a fresh dashboard link and approve the browser device:
docker compose run --rm coderclaw-cli dashboard --no-open
docker compose run --rm coderclaw-cli devices list
docker compose run --rm coderclaw-cli devices approve <requestId>
More detail: Dashboard, Devices.
If you want to mount additional host directories into the containers, set
CODERCLAW_EXTRA_MOUNTS before running docker-setup.sh. This accepts a
comma-separated list of Docker bind mounts and applies them to both
coderclaw-gateway and coderclaw-cli by generating docker-compose.extra.yml.
Example:
export CODERCLAW_EXTRA_MOUNTS="$HOME/.codex:/home/node/.codex:ro,$HOME/github:/home/node/github:rw"
./docker-setup.sh
Notes:
CODERCLAW_EXTRA_MOUNTS, rerun docker-setup.sh to regenerate the
extra compose file.docker-compose.extra.yml is generated. Don’t hand-edit it.If you want /home/node to persist across container recreation, set a named
volume via CODERCLAW_HOME_VOLUME. This creates a Docker volume and mounts it at
/home/node, while keeping the standard config/workspace bind mounts. Use a
named volume here (not a bind path); for bind mounts, use
CODERCLAW_EXTRA_MOUNTS.
Example:
export CODERCLAW_HOME_VOLUME="coderclaw_home"
./docker-setup.sh
You can combine this with extra mounts:
export CODERCLAW_HOME_VOLUME="coderclaw_home"
export CODERCLAW_EXTRA_MOUNTS="$HOME/.codex:/home/node/.codex:ro,$HOME/github:/home/node/github:rw"
./docker-setup.sh
Notes:
CODERCLAW_HOME_VOLUME, rerun docker-setup.sh to regenerate the
extra compose file.docker volume rm <name>.If you need system packages inside the image (for example, build tools or media
libraries), set CODERCLAW_DOCKER_APT_PACKAGES before running docker-setup.sh.
This installs the packages during the image build, so they persist even if the
container is deleted.
Example:
export CODERCLAW_DOCKER_APT_PACKAGES="ffmpeg build-essential"
./docker-setup.sh
Notes:
CODERCLAW_DOCKER_APT_PACKAGES, rerun docker-setup.sh to rebuild
the image.The default Docker image is security-first and runs as the non-root node
user. This keeps the attack surface small, but it means:
If you want a more full-featured container, use these opt-in knobs:
/home/node so browser downloads and tool caches survive:export CODERCLAW_HOME_VOLUME="coderclaw_home"
./docker-setup.sh
export CODERCLAW_DOCKER_APT_PACKAGES="git curl jq"
./docker-setup.sh
npx (avoids npm override conflicts):docker compose run --rm coderclaw-cli \
node /app/node_modules/playwright-core/cli.js install chromium
If you need Playwright to install system deps, rebuild the image with
CODERCLAW_DOCKER_APT_PACKAGES instead of using --with-deps at runtime.
PLAYWRIGHT_BROWSERS_PATH=/home/node/.cache/ms-playwright in
docker-compose.yml./home/node persists via CODERCLAW_HOME_VOLUME, or mount
/home/node/.cache/ms-playwright via CODERCLAW_EXTRA_MOUNTS.The image runs as node (uid 1000). If you see permission errors on
/home/node/.coderclaw, make sure your host bind mounts are owned by uid 1000.
Example (Linux host):
sudo chown -R 1000:1000 /path/to/coderclaw-config /path/to/coderclaw-workspace
If you choose to run as root for convenience, you accept the security tradeoff.
To speed up rebuilds, order your Dockerfile so dependency layers are cached.
This avoids re-running pnpm install unless lockfiles change:
FROM node:22-bookworm
# Install Bun (required for build scripts)
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:${PATH}"
RUN corepack enable
WORKDIR /app
# Cache dependencies unless package metadata changes
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
COPY ui/package.json ./ui/package.json
COPY scripts ./scripts
RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm build
RUN pnpm ui:install
RUN pnpm ui:build
ENV NODE_ENV=production
CMD ["node","dist/index.js"]
Use the CLI container to configure channels, then restart the gateway if needed.
WhatsApp (QR):
docker compose run --rm coderclaw-cli channels login
Telegram (bot token):
docker compose run --rm coderclaw-cli channels add --channel telegram --token "<token>"
Discord (bot token):
docker compose run --rm coderclaw-cli channels add --channel discord --token "<token>"
Docs: WhatsApp, Telegram, Discord
If you pick OpenAI Codex OAuth in the wizard, it opens a browser URL and tries
to capture a callback on http://127.0.0.1:1455/auth/callback. In Docker or
headless setups that callback can show a browser error. Copy the full redirect
URL you land on and paste it back into the wizard to finish auth.
docker compose exec coderclaw-gateway node dist/index.js health --token "$CODERCLAW_GATEWAY_TOKEN"
scripts/e2e/onboard-docker.sh
pnpm test:docker:qr
lan for container use.--allow-unconfigured; mounted config with gateway.mode not local will still start. Override CMD to enforce the guard.~/.coderclaw/agents/<agentId>/sessions/).Deep dive: Sandboxing
When agents.defaults.sandbox is enabled, non-main sessions run tools inside a Docker
container. The gateway stays on your host, but the tool execution is isolated:
"agent" by default (one container + workspace per agent)"session" for per-session isolation/workspaceagents.defaults.sandbox.workspaceAccess)media/inbound/*) so tools can read it (with workspaceAccess: "rw", this lands in the agent workspace)Warning: scope: "shared" disables cross-session isolation. All sessions share
one container and one workspace.
If you use multi-agent routing, each agent can override sandbox + tool settings:
agents.list[].sandbox and agents.list[].tools (plus agents.list[].tools.sandbox.tools). This lets you run
mixed access levels in one gateway:
See Multi-Agent Sandbox & Tools for examples, precedence, and troubleshooting.
coderclaw-sandbox:bookworm-slimworkspaceAccess: "none" (default) uses ~/.coderclaw/sandboxes
"ro" keeps the sandbox workspace at /workspace and mounts the agent workspace read-only at /agent (disables write/edit/apply_patch)"rw" mounts the agent workspace read/write at /workspacenone by default (explicitly opt-in if you need egress)exec, process, read, write, edit, sessions_list, sessions_history, sessions_send, sessions_spawn, session_statusbrowser, canvas, nodes, cron, discord, gatewayIf you plan to install packages in setupCommand, note:
docker.network is "none" (no egress).readOnlyRoot: true blocks package installs.user must be root for apt-get (omit user or set user: "0:0").
CoderClaw auto-recreates containers when setupCommand (or docker config) changes
unless the container was recently used (within ~5 minutes). Hot containers
log a warning with the exact coderclaw sandbox recreate ... command.{
agents: {
defaults: {
sandbox: {
mode: "non-main", // off | non-main | all
scope: "agent", // session | agent | shared (agent is default)
workspaceAccess: "none", // none | ro | rw
workspaceRoot: "~/.coderclaw/sandboxes",
docker: {
image: "coderclaw-sandbox:bookworm-slim",
workdir: "/workspace",
readOnlyRoot: true,
tmpfs: ["/tmp", "/var/tmp", "/run"],
network: "none",
user: "1000:1000",
capDrop: ["ALL"],
env: { LANG: "C.UTF-8" },
setupCommand: "apt-get update && apt-get install -y git curl jq",
pidsLimit: 256,
memory: "1g",
memorySwap: "2g",
cpus: 1,
ulimits: {
nofile: { soft: 1024, hard: 2048 },
nproc: 256,
},
seccompProfile: "/path/to/seccomp.json",
apparmorProfile: "coderclaw-sandbox",
dns: ["1.1.1.1", "8.8.8.8"],
extraHosts: ["internal.service:10.0.0.5"],
},
prune: {
idleHours: 24, // 0 disables idle pruning
maxAgeDays: 7, // 0 disables max-age pruning
},
},
},
},
tools: {
sandbox: {
tools: {
allow: [
"exec",
"process",
"read",
"write",
"edit",
"sessions_list",
"sessions_history",
"sessions_send",
"sessions_spawn",
"session_status",
],
deny: ["browser", "canvas", "nodes", "cron", "discord", "gateway"],
},
},
},
}
Hardening knobs live under agents.defaults.sandbox.docker:
network, user, pidsLimit, memory, memorySwap, cpus, ulimits,
seccompProfile, apparmorProfile, dns, extraHosts.
Multi-agent: override agents.defaults.sandbox.{docker,browser,prune}.* per agent via agents.list[].sandbox.{docker,browser,prune}.*
(ignored when agents.defaults.sandbox.scope / agents.list[].sandbox.scope is "shared").
scripts/sandbox-setup.sh
This builds coderclaw-sandbox:bookworm-slim using Dockerfile.sandbox.
If you want a sandbox image with common build tooling (Node, Go, Rust, etc.), build the common image:
scripts/sandbox-common-setup.sh
This builds coderclaw-sandbox-common:bookworm-slim. To use it:
{
agents: {
defaults: {
sandbox: { docker: { image: "coderclaw-sandbox-common:bookworm-slim" } },
},
},
}
To run the browser tool inside the sandbox, build the browser image:
scripts/sandbox-browser-setup.sh
This builds coderclaw-sandbox-browser:bookworm-slim using
Dockerfile.sandbox-browser. The container runs Chromium with CDP enabled and
an optional noVNC observer (headful via Xvfb).
Notes:
agents.defaults.sandbox.browser.headless=true.Use config:
{
agents: {
defaults: {
sandbox: {
browser: { enabled: true },
},
},
},
}
Custom browser image:
{
agents: {
defaults: {
sandbox: { browser: { image: "my-coderclaw-browser" } },
},
},
}
When enabled, the agent receives:
browser tool)Remember: if you use an allowlist for tools, add browser (and remove it from
deny) or the tool remains blocked.
Prune rules (agents.defaults.sandbox.prune) apply to browser containers too.
Build your own image and point config to it:
docker build -t my-coderclaw-sbx -f Dockerfile.sandbox .
{
agents: {
defaults: {
sandbox: { docker: { image: "my-coderclaw-sbx" } },
},
},
}
deny wins over allow.allow is empty: all tools (except deny) are available.allow is non-empty: only tools in allow are available (minus deny).Two knobs:
prune.idleHours: remove containers not used in X hours (0 = disable)prune.maxAgeDays: remove containers older than X days (0 = disable)Example:
idleHours: 24, maxAgeDays: 7idleHours: 0, maxAgeDays: 0browser in sandbox breaks isolation (browser runs on host).scripts/sandbox-setup.sh or set agents.defaults.sandbox.docker.image.docker.user to a UID:GID that matches your
mounted workspace ownership (or chown the workspace folder).sh -lc (login shell), which
sources /etc/profile and may reset PATH. Set docker.env.PATH to prepend your
custom tool paths (e.g., /custom/bin:/usr/local/share/npm-global/bin), or add
a script under /etc/profile.d/ in your Dockerfile.