Docker deployment provides isolation, easy management, and consistent environments. This guide covers deploying OpenClaw using Docker and docker-compose.

Quick Start with Docker

Prerequisites

  • Docker installed and running
  • Docker Compose (optional, for easier management)
  • Basic Docker knowledge

Basic Docker Run

Docker Run
docker run -d \
  --name openclaw \
  -p 18789:18789 \
  -v ~/.clawdbot:/root/.clawdbot \
  -v ~/clawd:/root/clawd \
  openclaw/openclaw:latest \
  openclaw gateway

Docker Compose Setup

Using docker-compose makes management easier:

docker-compose.yml

docker-compose.yml
version: '3.8'

services:
  openclaw:
    image: openclaw/openclaw:latest
    container_name: openclaw
    restart: unless-stopped
    ports:
      - "18789:18789"
      - "18793:18793"
    volumes:
      - ~/.clawdbot:/root/.clawdbot
      - ~/clawd:/root/clawd
    environment:
      - NODE_ENV=production
    command: openclaw gateway

Starting with Compose

Start Service
docker-compose up -d

Volume Management

Important directories to persist:

  • Configuration: ~/.clawdbot - Contains config and credentials
  • Workspace: ~/clawd - Contains memories, skills, sessions

Volume Mounting

Mount volumes to persist data:

Volume Mounts
volumes:
  - ~/.clawdbot:/root/.clawdbot
  - ~/clawd:/root/clawd

Network Configuration

Port Mapping

Map required ports:

  • 18789 - Gateway WebSocket (default)
  • 18793 - Canvas host (default)

Network Mode

For better isolation, use bridge network:

Network Config
networks:
  moltbot-network:
    driver: bridge

Environment Variables

Configure via environment variables:

Environment Variables
environment:
  - NODE_ENV=production
  - CLAWDBOT_CONFIG_PATH=/root/.clawdbot/moltbot.json
  - CLAWDBOT_STATE_DIR=/root/.clawdbot

Sandboxing in Docker

Docker provides natural sandboxing:

  • Isolation - Container isolation from host
  • Resource Limits - CPU and memory limits
  • Network Isolation - Separate network namespace

Resource Limits

Resource Limits
deploy:
  resources:
    limits:
      cpus: '2'
      memory: 2G
    reservations:
      cpus: '1'
      memory: 1G

Managing the Container

Common Commands

Container Management
# Start
docker-compose up -d

# Stop
docker-compose down

# View logs
docker-compose logs -f

# Restart
docker-compose restart

# Execute commands
docker-compose exec openclaw openclaw status

# Update
docker-compose pull
docker-compose up -d

Updating OpenClaw

Update the container:

Update Process
# Pull latest image
docker-compose pull

# Restart with new image
docker-compose up -d

Troubleshooting Docker Issues

Container Won't Start

Check logs:

View Logs
docker-compose logs openclaw

Permission Issues

If you encounter permission errors:

  • Check volume mount permissions
  • Ensure user has access to mounted directories
  • Check Docker daemon permissions

Port Conflicts

If ports are already in use:

  • Change port mappings in docker-compose.yml
  • Stop conflicting services
  • Check: docker ps for running containers

Best Practices

  • Use Volumes - Persist configuration and workspace
  • Set Resource Limits - Prevent resource exhaustion
  • Use Restart Policy - Auto-restart on failure
  • Regular Updates - Keep image updated
  • Backup Volumes - Regular backups of data
  • Monitor Logs - Check logs regularly

Next Steps