Docker wrapper files for running the published
openclaw package in containers.
The root Dockerfile now uses a cache-aware multi-stage build: one stage
installs the published package with pnpm, and the final runtime stage copies
only the installed runtime artifacts. Because the image doesn't copy repository
content into the image, the Docker build context is intentionally reduced to the
Dockerfile itself.
- Multi-stage Docker build for a leaner runtime image
- BuildKit cache mounts for
aptandpnpmto speed rebuilds pnpm-based installation of the publishedopenclawpackage- Configurable runtime user name, UID, and GID
- Root-context Docker builds that do not read from
./openclaw - Shared image for
openclaw-gatewayandopenclaw-cli - Optional browser and Docker CLI support via build args
- Multi-platform
docker buildx baketarget
- Docker Engine 20.10+
- Docker Compose v2+
-
Clone this repository:
git clone https://github.com/dceoy/docker-openclaw.git cd docker-openclaw -
Copy the example environment file:
cp .env.example .env
-
Edit
.envand set the values you need. In most cases you will want at least:OPENCLAW_GATEWAY_TOKEN=change-me-to-a-long-random-token ANTHROPIC_API_KEY=...
-
Create the host directories used by bind mounts:
mkdir -p .openclaw workspace
-
Build and start the gateway:
docker compose up -d --build openclaw-gateway
-
Run onboarding or other CLI flows as needed:
docker compose run --rm openclaw-cli onboard
docker compose up -d openclaw-gatewayDefault endpoints:
- HTTP:
http://127.0.0.1:18789 - Bridge/WebSocket:
ws://127.0.0.1:18790
The published bind mode is controlled by OPENCLAW_GATEWAY_BIND and should use
OpenClaw bind values such as lan or loopback.
docker compose run --rm openclaw-cli
docker compose run --rm openclaw-cli onboard
docker compose run --rm openclaw-cli dashboard --no-open
docker compose run -T --rm openclaw-cli devices list --jsonSet OPENCLAW_INSTALL_BROWSER=1 in .env, then rebuild:
docker compose build
docker compose up -d openclaw-gatewaySet OPENCLAW_INSTALL_DOCKER_CLI=1 in .env, rebuild the image, and mount the
host Docker socket into the container if you want Docker-backed agent sandboxing.
The root Compose file does not mount the socket by default.
docker compose builddocker buildx bakedocker buildx bake now reads the build definition directly from compose.yml.
The default bake target is openclaw-gateway, so no separate docker-bake.hcl
file is required.
DOCKER_BUILDKIT=1 docker build -t openclaw:local .Example overrides:
OPENCLAW_VERSION=latest docker buildx bake
OPENCLAW_NODE_VERSION=22 docker buildx bake
OPENCLAW_USER_NAME=developer docker buildx bake
OPENCLAW_INSTALL_BROWSER=1 docker buildx bakeThe Dockerfile relies on BuildKit cache mounts. docker compose build and
docker buildx bake already use BuildKit; set DOCKER_BUILDKIT=1 for plain
docker build if your Docker installation doesn't enable it by default.
For direct docker build usage, pass the runtime-user build args explicitly
when needed:
DOCKER_BUILDKIT=1 docker build \
--build-arg USER_NAME=developer \
--build-arg USER_UID=1001 \
--build-arg USER_GID=1001 \
-t openclaw:local .| Variable | Default | Description |
|---|---|---|
OPENCLAW_IMAGE |
openclaw:local |
Image name and tag used by Compose and Bake |
OPENCLAW_NODE_VERSION |
22 |
Node.js major version used for the base image |
OPENCLAW_VERSION |
latest |
Published OpenClaw package version installed by pnpm |
OPENCLAW_USER_NAME |
claw |
Runtime username passed to Docker build arg USER_NAME |
OPENCLAW_USER_UID |
1001 |
Runtime UID passed to Docker build arg USER_UID |
OPENCLAW_USER_GID |
1001 |
Runtime GID passed to Docker build arg USER_GID |
OPENCLAW_DOCKER_APT_PACKAGES |
- | Extra apt packages added to the runtime image |
OPENCLAW_INSTALL_BROWSER |
- | Set to 1 to install Chromium + Xvfb |
OPENCLAW_INSTALL_DOCKER_CLI |
- | Set to 1 to add Docker CLI support |
OPENCLAW_CONFIG_DIR |
./.openclaw |
Host path mounted to /home/<user>/.openclaw |
OPENCLAW_WORKSPACE_DIR |
./workspace |
Host path mounted to /home/<user>/.openclaw/workspace |
OPENCLAW_GATEWAY_BIND |
lan |
Gateway bind mode passed to OpenClaw |
OPENCLAW_GATEWAY_PORT |
18789 |
Published HTTP port |
OPENCLAW_BRIDGE_PORT |
18790 |
Published bridge/WebSocket port |
OPENCLAW_GATEWAY_TOKEN |
- | Gateway auth token |
OPENCLAW_ALLOW_INSECURE_PRIVATE_WS |
- | Allow trusted private-network ws:// targets |
The Compose file also passes these optional provider variables through to the
containers when present in .env:
CLAUDE_AI_SESSION_KEYCLAUDE_WEB_SESSION_KEYCLAUDE_WEB_COOKIEOPENAI_API_KEYANTHROPIC_API_KEYGEMINI_API_KEYOPENROUTER_API_KEYELEVENLABS_API_KEY
<user> resolves to OPENCLAW_USER_NAME and defaults to claw.
| Container path | Description |
|---|---|
/home/<user>/.openclaw |
OpenClaw state, config, and sessions |
/home/<user>/.openclaw/workspace |
Workspace used by agents and tools |
| Service | Description |
|---|---|
openclaw-gateway |
Main gateway container |
openclaw-cli |
Interactive CLI container that shares the gateway network namespace |