Deploy OpenClaw (formerly Clawdbot and Moltbot) using Docker containers
Docker deployment provides isolation, easy management, and consistent environments. This guide covers deploying OpenClaw using Docker and docker-compose.
docker run -d \
--name openclaw \
-p 18789:18789 \
-v ~/.clawdbot:/root/.clawdbot \
-v ~/clawd:/root/clawd \
openclaw/openclaw:latest \
openclaw gateway
Using docker-compose makes management easier:
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
docker-compose up -d
Important directories to persist:
~/.clawdbot - Contains config and credentials~/clawd - Contains memories, skills, sessionsMount volumes to persist data:
volumes:
- ~/.clawdbot:/root/.clawdbot
- ~/clawd:/root/clawd
Map required ports:
For better isolation, use bridge network:
networks:
moltbot-network:
driver: bridge
Configure via environment variables:
environment:
- NODE_ENV=production
- CLAWDBOT_CONFIG_PATH=/root/.clawdbot/moltbot.json
- CLAWDBOT_STATE_DIR=/root/.clawdbot
Docker provides natural sandboxing:
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '1'
memory: 1G
# 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
Update the container:
# Pull latest image
docker-compose pull
# Restart with new image
docker-compose up -d
Check logs:
docker-compose logs openclaw
If you encounter permission errors:
If ports are already in use:
docker ps for running containers