# OpenClaw Docker Compose setup and first run

Canonical: https://cwyn.com/pages/openclaw-guide-docker-compose-first-run.html
Last updated: 2026-11-27T06:09:14-05:00

OpenClaw operations guide

This OpenClaw Docker Compose setup runs the official image and keeps your configuration and workspace in a Docker volume. Run onboarding once to connect your model provider, then start the Gateway. Open the dashboard on the Docker host or through an SSH tunnel and send a chat message to verify the model replies.

Last updated November 27, 2026 · Published November 19, 2026

By CWYN · Nov 27, 2026 · Checked against docs, not run · [OpenClaw Docker installation guide](https://docs.openclaw.ai/install/docker)

## 1. Check the Docker host

Use Docker Desktop or Docker Engine with Compose v2 and have your hosted model provider credentials ready. For a small Gateway, budget 1 to 2 vCPUs and at least 2 GB RAM. Allow local disk space for the image, logs, workspace and backups. Building the image from source takes at least 6 GB RAM. This guide pulls the prebuilt image. [OpenClaw host sizing](https://docs.openclaw.ai/help/faq-first-run/providers-and-hosting).

```
docker compose version
```

Check that Docker prints a Compose version. Create a fresh project folder and run the remaining Docker commands from that folder in a Bash-compatible terminal.

## 2. Save the Compose file

Save this complete file as `docker-compose.yml`. Both services use the official stable image and share their volumes. The Gateway runs continuously. The CLI runs on demand and shares the running Gateway’s network and process namespaces. [Upstream Compose file](https://github.com/openclaw/openclaw/blob/main/docker-compose.yml).

```
x-openclaw: &openclaw
  image: ghcr.io/openclaw/openclaw:latest
  volumes:
    - openclaw-data:/home/node/.openclaw
    - openclaw-keys:/home/node/.config/openclaw
  cap_drop: [NET_RAW, NET_ADMIN]
  security_opt: ["no-new-privileges:true"]

services:
  openclaw-gateway:
    <<: *openclaw
    init: true
    restart: unless-stopped
    command: ["node", "dist/index.js", "gateway", "--bind", "lan", "--port", "18789"]
    ports:
      - "127.0.0.1:18789:18789"
  openclaw-cli:
    <<: *openclaw
    entrypoint: ["node", "dist/index.js"]
    network_mode: "service:openclaw-gateway"
    pid: "service:openclaw-gateway"
    depends_on: [openclaw-gateway]

volumes:
  openclaw-data: {}
  openclaw-keys: {}
```

`openclaw-data` holds `/home/node/.openclaw/openclaw.json`, session data and the default `/home/node/.openclaw/workspace`. The second volume preserves auth-profile keys. Keep both on local storage and treat backups as credentials. The `lan` bind lets Docker forward traffic inside the container. The `127.0.0.1` host mapping keeps the dashboard private. [OpenClaw networking and storage](https://docs.openclaw.ai/install/docker/networking-and-storage).

## 3. Run first-time onboarding

Pull the image, then start the wizard in a temporary Gateway container. This writes to the volumes before the long-running Gateway starts.

```
docker compose pull openclaw-gateway openclaw-cli
docker compose run --rm --no-deps --entrypoint node openclaw-gateway \
  dist/index.js onboard --mode local --flow quickstart --gateway-auth token --no-install-daemon
```

Choose your model provider, enter its credentials at the prompt and select a model your account can use. Keep the default workspace and let the wizard generate the Gateway token. Compose will manage the service. [Onboarding options](https://docs.openclaw.ai/cli/onboard).

Allow the two local dashboard addresses, then start the Gateway. A successful health check returns HTTP 200 from the container.

```
docker compose run --rm --no-deps --entrypoint node openclaw-gateway \
  dist/index.js config set --batch-json '[
    {"path":"gateway.mode","value":"local"},
    {"path":"gateway.bind","value":"lan"},
    {"path":"gateway.controlUi.allowedOrigins","value":["http://localhost:18789","http://127.0.0.1:18789"]}
  ]'
docker compose up -d openclaw-gateway
curl -fsS http://127.0.0.1:18789/healthz
```

## 4. Open the dashboard and check the first reply

On the Docker host, open `http://127.0.0.1:18789/`. For a remote host, run the following command on your laptop, substituting your SSH login and hostname. Keep that terminal open and use the same local URL in your laptop browser. Only SSH needs to be reachable on the server.

```
ssh -N -L 18789:127.0.0.1:18789 user@gateway-host
```

If prompted for Gateway secret, run the command below in a private terminal on the Docker host and paste the token into the dashboard. Keep it out of chat and logs. Send “Reply with ready” in the Control UI chat. A model reply confirms that the provider credentials work. [Dashboard access and authentication](https://docs.openclaw.ai/web/dashboard).

```
docker compose exec openclaw-gateway openclaw gateway auth-token --show
```

After the first reply, use the [tool profile patches in the OpenClaw Complete Setup Pack](https://cwyn.com/pages/pack-openclaw-complete-setup-pack.html) if you want a preset for the tools your new agent can use.

## 5. Update the image and keep your data

Back up both volumes before upgrading. From the same project folder, pull the current stable image. Stop the old Gateway so its replacement has exclusive access to the data during startup. [OpenClaw image upgrade procedure](https://docs.openclaw.ai/install/docker#upgrading-container-images).

```
docker compose pull openclaw-gateway openclaw-cli
docker compose stop openclaw-gateway
docker compose up -d openclaw-gateway
```

Repeat the health check, then reopen the dashboard. Your existing workspace and chat history should still be there. Send a message to check the model after the upgrade.

## 6. Troubleshooting Docker Compose

Run `docker compose ps` to see the Gateway status and host port. Use `docker compose logs -f openclaw-gateway` for the startup error. [Compose commands and permission fixes](https://docs.openclaw.ai/install/docker/compose-operations).

### Port is already allocated

Another process owns host port 18789. Identify the listener before stopping it. If it is an obsolete Gateway you manage, stop that instance and rerun the start command. [Identify the Gateway using the port](https://cwyn.com/pages/openclaw-guide-gateway-port-already-in-use.html).

### Connection refused on localhost

Check the health URL on the Docker host first. If startup is still in progress, wait for the listener and retry. If the container is running, check that its bind is `lan` and the published address is `127.0.0.1:18789:18789`. If the host probe works but the laptop cannot connect, reopen the SSH tunnel.

### The dashboard says unauthorized

Retrieve the current Gateway token with the command in step 4 and enter it in Gateway secret. The model provider’s API key belongs in onboarding.

### The browser reports pairing required (1008)

Run `docker compose run --rm openclaw-cli devices list`. Match the pending request to the browser you just connected. Replace `<requestId>` in `docker compose run --rm openclaw-cli devices approve <requestId>` with that ID, then reconnect. [Verify the browser’s Gateway pairing request](https://cwyn.com/pages/openclaw-guide-gateway-device-pairing.html).

### Configuration disappears after an update

Check the Compose project name and volume mounts. A renamed project folder can select a new, empty volume. Stop that Gateway, return to the original project and start it with the original volumes. Keep both volumes when replacing containers.

### EACCES writing to the workspace

The image runs as the `node` user (UID 1000). If you restored files or substituted a Linux bind mount, check ownership on the mounted config and workspace directories. Restore write access for UID 1000 on those directories, then retry the failed write.

[Get your free CWYN Score](https://cwyn.com/pages/score.html)

## Related guides

- [OpenClaw Docker config keeps resetting: check persistent mounts](https://cwyn.com/pages/openclaw-guide-docker-config-not-persisting.html)
- [Set up your first OpenClaw Telegram bot](https://cwyn.com/pages/openclaw-guide-first-telegram-bot.html)
- [Install OpenClaw on Windows with WSL2](https://cwyn.com/pages/openclaw-guide-windows-wsl2-install.html)
- [OpenClaw on Raspberry Pi: install and open the dashboard over SSH](https://cwyn.com/pages/openclaw-guide-raspberry-pi-ssh-setup.html)

## Next steps

- [All 135 OpenClaw guides](https://cwyn.com/guides/openclaw/)
- [OpenClaw setup walkthrough](https://cwyn.com/setup/openclaw/)
- [CWYN Score](https://cwyn.com/pages/score.html)
- [OpenClaw Complete Setup Pack ($14.95)](https://cwyn.com/pages/pack-openclaw-complete-setup-pack.html)

### Pair a private channel with the new Gateway

The [OpenClaw Complete Setup Pack ($14.95)](https://cwyn.com/pages/pack-openclaw-complete-setup-pack.html) is an optional paid kit with a Telegram pairing checklist for testing a private reply after the Compose setup works.
Kit details as of Nov 18, 2026

OpenClaw Complete Setup Pack $14.95

Start an OpenClaw workspace with editable instructions, local Gateway and tool presets, and checklists for pairing, memory, costs and rollback.
