🦞OpenClaw Guide
🐳 Docker

OpenClaw on Docker

Containerized OpenClaw with Docker Compose. Persistent config, auto-restart, clean env var management. Copy the compose file and go.

docker-compose.yml

services:
  openclaw:
    image: node:20-alpine
    container_name: openclaw
    restart: unless-stopped
    working_dir: /app
    environment:
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - HOME=/app
    volumes:
      - openclaw-config:/app/.openclaw
    command: >
      sh -c "npm install -g openclaw &&
             openclaw gateway start"
    ports:
      - "18789:18789"

volumes:
  openclaw-config:

.env file (same directory)

ANTHROPIC_API_KEY=sk-ant-your-key-here
OPENAI_API_KEY=sk-your-key-here

Start it up

docker compose up -d
docker compose logs -f openclaw

Common commands

Start (background)
docker compose up -d
View logs
docker compose logs -f openclaw
Stop
docker compose down
Restart
docker compose restart openclaw
Update OpenClaw
docker compose down && docker compose pull && docker compose up -d
Check status
docker compose ps

Docker FAQ

Can I run OpenClaw in Docker?

Yes. OpenClaw is a Node.js application and runs cleanly in Docker containers. The recommended approach is Docker Compose with a persistent volume for your ~/.openclaw config directory, so settings and skills survive container restarts.

Does OpenClaw have an official Docker image?

Not an official one. Use the node:20-alpine base image and install OpenClaw via npm. The docker-compose.yml on this page is the community-standard approach. It mounts a named volume for config persistence.

How do I persist my OpenClaw config in Docker?

Use a named volume mapped to /app/.openclaw in the container. The docker-compose.yml above includes this: the openclaw-config volume stores your API keys, skills, and settings between container restarts and image updates.

Can I run Docker OpenClaw on a VPS?

Yes, and it's a clean setup. SSH into your VPS, install Docker, copy the docker-compose.yml and .env file, run docker compose up -d. Your OpenClaw runs containerized, restarts on failure, and is easy to update. See the VPS guide for the full walkthrough.

How do I update OpenClaw in Docker?

Since OpenClaw is installed at container startup via npm install -g openclaw, pull the latest node image and recreate: docker compose down && docker compose pull && docker compose up -d --build. Or add a specific version pin: npm install -g openclaw@x.x.x.

What ports does OpenClaw use in Docker?

Port 18789 is the OpenClaw gateway port. Exposed in the compose file above. You only need this accessible if you're using the web UI or connecting other services to the gateway. For Telegram/WhatsApp-only setups, you can remove the ports section entirely — OpenClaw connects outbound.