Local Deployment

Openclaw Docker Setup Guide

Deploy Openclaw using Docker containers for maximum portability and isolation. Complete guide for Docker and Docker Compose installation.

This comprehensive guide covers openclaw docker setup for developers who prefer containerized deployments. Docker provides consistent environments across different platforms, making your openclaw installation portable and reproducible.

Why Choose Docker for Openclaw?

Openclaw docker deployment offers several advantages:

  • Portability: Run openclaw docker containers on any system with Docker support
  • Isolation: Keep Openclaw separate from your host system
  • Reproducibility: Consistent environment across development and production
  • Easy Updates: Simple container replacement for upgrades
  • Scalability: Easy to scale with Docker Compose or Kubernetes

Prerequisites for Openclaw Docker Setup

Before starting your openclaw docker installation, ensure you have:

Docker Installation

Install Docker on your system:

macOS:

# Install Docker Desktop
brew install --cask docker

Ubuntu/Debian:

# Install Docker Engine
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER

Windows: Download and install Docker Desktop for Windows.

Verify Docker Installation

docker --version
docker compose version

Quick Openclaw Docker Setup

For a fast openclaw docker deployment, follow these steps:

Step 1: Clone the Repository

git clone https://github.com/openclaw/openclaw.git
cd openclaw

Step 2: Configure Environment

cp .env.example .env
nano .env

Add your configuration:

ANTHROPIC_API_KEY=your_api_key_here
NODE_ENV=production
PORT=3000

Step 3: Build and Run

# Build the Docker image
docker build -t openclaw .

# Run the container
docker run -d \
  --name openclaw \
  -p 3000:3000 \
  --env-file .env \
  --restart unless-stopped \
  openclaw

Your openclaw docker container is now running at http://localhost:3000.

Docker Compose for Openclaw Setup

For more complex openclaw docker deployments, use Docker Compose:

Create docker-compose.yml

version: '3.8'

services:
  openclaw:
    build: .
    container_name: openclaw
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - PORT=3000
    env_file:
      - .env
    restart: unless-stopped
    volumes:
      - openclaw_data:/app/data
      - openclaw_logs:/app/logs
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
      interval: 30s
      timeout: 10s
      retries: 3

volumes:
  openclaw_data:
  openclaw_logs:

Start with Docker Compose

# Start in detached mode
docker compose up -d

# View logs
docker compose logs -f

# Stop containers
docker compose down

Dockerfile Configuration

If you need to customize your openclaw docker build, here's a sample Dockerfile:

FROM node:20-alpine AS builder

WORKDIR /app

# Install dependencies
COPY package*.json ./
RUN npm ci --only=production

# Copy source code
COPY . .

# Build application
RUN npm run build

# Production stage
FROM node:20-alpine AS runner

WORKDIR /app

# Create non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 openclaw

# Copy built application
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

USER openclaw

EXPOSE 3000

CMD ["node", "dist/index.js"]

Managing Your Openclaw Docker Container

View Running Containers

docker ps

View Logs

# Follow logs
docker logs -f openclaw

# Last 100 lines
docker logs --tail 100 openclaw

Restart Container

docker restart openclaw

Stop and Remove

docker stop openclaw
docker rm openclaw

Update Openclaw Docker Image

# Pull latest code
git pull origin main

# Rebuild image
docker build -t openclaw .

# Stop old container
docker stop openclaw
docker rm openclaw

# Start new container
docker run -d \
  --name openclaw \
  -p 3000:3000 \
  --env-file .env \
  --restart unless-stopped \
  openclaw

Openclaw Docker with Nginx Reverse Proxy

For production openclaw docker setups, use Nginx as a reverse proxy:

docker-compose.yml with Nginx

version: '3.8'

services:
  openclaw:
    build: .
    container_name: openclaw
    expose:
      - "3000"
    env_file:
      - .env
    restart: unless-stopped
    networks:
      - openclaw-network

  nginx:
    image: nginx:alpine
    container_name: openclaw-nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - ./ssl:/etc/nginx/ssl:ro
    depends_on:
      - openclaw
    restart: unless-stopped
    networks:
      - openclaw-network

networks:
  openclaw-network:
    driver: bridge

nginx.conf

events {
    worker_connections 1024;
}

http {
    upstream openclaw {
        server openclaw:3000;
    }

    server {
        listen 80;
        server_name your-domain.com;
        return 301 https://$server_name$request_uri;
    }

    server {
        listen 443 ssl;
        server_name your-domain.com;

        ssl_certificate /etc/nginx/ssl/cert.pem;
        ssl_certificate_key /etc/nginx/ssl/key.pem;

        location / {
            proxy_pass http://openclaw;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_cache_bypass $http_upgrade;
        }
    }
}

Resource Limits for Openclaw Docker

Control resource usage in your openclaw docker deployment:

services:
  openclaw:
    build: .
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 4G
        reservations:
          cpus: '1'
          memory: 2G

Or with docker run:

docker run -d \
  --name openclaw \
  --cpus="2" \
  --memory="4g" \
  -p 3000:3000 \
  --env-file .env \
  openclaw

Troubleshooting Openclaw Docker Issues

Container Won't Start

# Check logs
docker logs openclaw

# Check container status
docker inspect openclaw

Port Already in Use

# Find process using port
lsof -i :3000

# Use different port
docker run -d -p 3001:3000 --name openclaw openclaw

Permission Issues

# Fix volume permissions
sudo chown -R 1001:1001 ./data

Out of Memory

Increase Docker memory limits in Docker Desktop settings, or add resource limits to your container.

Openclaw Docker Security Best Practices

Secure your openclaw docker deployment:

  1. Use non-root user: Run containers as non-root (shown in Dockerfile above)
  2. Limit resources: Prevent resource exhaustion attacks
  3. Use secrets: Store API keys in Docker secrets, not environment variables
  4. Network isolation: Use custom networks to isolate containers
  5. Regular updates: Keep base images updated

Using Docker Secrets

services:
  openclaw:
    build: .
    secrets:
      - anthropic_api_key
    environment:
      - ANTHROPIC_API_KEY_FILE=/run/secrets/anthropic_api_key

secrets:
  anthropic_api_key:
    file: ./secrets/anthropic_api_key.txt

Next Steps

Now that your openclaw docker setup is complete:

  1. Review Security Best Practices
  2. Compare with VPS Deployment options
  3. Check Hardware Requirements for scaling
Need Help?

Having trouble with your openclaw docker setup? Our $100 deployment service includes Docker configuration and optimization.