Hardened, containerized OpenClaw deployment following the official Docker guide and security recommendations.
OpenClaw runs an AI agent with tool access — file reads, web search, shell execution. Running it directly on the host means the agent operates with your user's full permissions: your files, your SSH keys, your credentials.
Docker isolates this:
- The container can only see
.openclaw/(config) andsandbox/(shared workspace) — nothing else on your filesystem - Port is bound to
127.0.0.1only — no network exposure - Linux capabilities are dropped (
NET_RAW,NET_ADMIN), privilege escalation is blocked - Memory and CPU limits prevent runaway resource consumption
- The agent workspace is restricted with
workspaceOnly: true— even inside the container, tools can't escape the workspace directory
- Docker and Docker Compose v2
- Python 3 (for config generation)
./dockerclaw.sh setupThis single command runs the full pipeline:
- Onboard — interactive setup (auth, provider selection)
- Harden — sets file permissions (700/600) on config directory
- Configure — reads
openclaw.ini, generates a JSON patch, deep-merges into the config - Start — launches the gateway container
- Install skills — pulls skills from ClawHub
- Dashboard — prints the tokenized dashboard URL
- Pair — monitors for browser pairing request and auto-approves (60s timeout)
Open the dashboard URL in your browser when prompted. The setup will detect and approve the pairing request automatically.
After setup, configure your model provider. For Claude Max/Pro subscriptions:
# On your host machine (not inside Docker), generate a setup token
claude setup-token
# Then configure the model provider
./dockerclaw.sh cli configure --section modelSelect Anthropic as the provider and paste the setup-token when prompted. You can also use an API key or any other supported provider.
If you're running OpenClaw on a Claude Max/Pro setup-token, optimize for smaller prompts and fewer expensive turns:
- Default to
claude-sonnet-4-6; keepclaude-opus-4-6as fallback/escalation only - Disable session transcript recall unless you truly need cross-session memory
- Keep
AGENTS.md,MEMORY.md,USER.md, andHEARTBEAT.mdconcise because OpenClaw injects them into every turn - Avoid installing optional skills by default; each additional skill increases prompt overhead
- Start fresh sessions for unrelated tasks instead of letting one long-running session accumulate history
Important: Anthropic setup-token auth is convenient, but prompt-caching benefits are tied to API-key usage rather than Claude subscription setup-token flows. If you later switch to Anthropic API keys, revisit caching-oriented optimizations separately.
./dockerclaw.sh prune
./dockerclaw.sh setupAll settings live in two files:
openclaw.ini— application config (gateway, tools, agents, hooks, skills)dockerclaw.env— container resource limits and Docker-level settings
Edit these files, then prune and setup to apply from scratch.
| Setting | Value | Why |
|---|---|---|
tools.fs.workspaceOnly |
true |
Restrict file access to workspace directory |
tools.exec.security |
deny |
Disable shell execution |
tools.exec.ask |
always |
Require approval for any exec |
tools.elevated.enabled |
false |
Disable privileged operations |
tools.deny |
automation, runtime, sessions | Block dangerous control-plane tools |
logging.redactSensitive |
tools |
Redact secrets in tool output logs |
discovery.mdns.mode |
minimal |
Reduce info disclosure on LAN |
| File permissions | 700/600 | Config directory and files restricted to owner |
| Setting | Value | Why |
|---|---|---|
compaction.memoryFlush.enabled |
true |
Flush durable memories to disk before context compaction |
memorySearch.experimental.sessionMemory |
false |
Avoid replaying old session transcripts into Claude context by default |
memorySearch.sources |
memory |
Prefer curated memory over full session-history recall |
- boot-md — loads a context file at session startup
- session-memory — auto-saves and recalls memory across sessions
For Claude-only setups, keep the boot files small. OpenClaw injects these workspace files into the prompt on every run:
AGENTS.mdSOUL.mdTOOLS.mdIDENTITY.mdUSER.mdHEARTBEAT.mdBOOTSTRAP.mdMEMORY.md
| Measure | Implementation |
|---|---|
| Network isolation | Port bound to 127.0.0.1 only |
| Capability dropping | NET_RAW, NET_ADMIN dropped |
| Privilege escalation | no-new-privileges: true |
| Resource limits | Configurable via dockerclaw.env (default 8 GB / 2 CPUs) |
| Health monitoring | /healthz endpoint checked every 30s |
| Filesystem isolation | Only .openclaw/ and sandbox/ mounted |
./dockerclaw.sh <command>
setup — onboard + configure + start + pair (reads from openclaw.ini)
prune — remove all containers, volumes, and config
start — start the gateway
stop — stop all containers
restart — restart the gateway
logs — tail gateway logs
status — show container status
get-token — print the gateway auth token
config — manage configuration (pass args to openclaw-cli)
skills — manage skills (pass args to openclaw-cli)
dashboard — print dashboard URL and approve device pairing
cli — run any openclaw-cli command
dockerclaw.sh — CLI wrapper (setup, lifecycle, config, pairing)
openclaw.ini — declarative app config (all settings in one place)
dockerclaw.env — container resource limits and Docker settings
scripts/ini2json.py — converts ini to JSON patch
docker-compose.yml — official service definitions (gateway + cli)
.openclaw/ — runtime config and data (gitignored)
sandbox/ — shared host directory mounted into workspace
openclaw.ini → ini2json.py → JSON patch → deep-merge into .openclaw/openclaw.json
No containers are spawned for configuration. The ini is converted to a JSON patch on the host and merged directly into the config file. Skills are the only post-start step (they need ClawHub network access).
The Control UI requires device pairing as a security measure. In Docker, browser connections arrive from the Docker bridge network, not loopback, so auto-approval doesn't apply. The setup and dashboard commands handle this by detecting pending pairing requests via openclaw-cli devices list and approving them with openclaw-cli devices approve.