Deploy OpenClaw with Docker: Complete Setup Guide (2026)
You want your AI agent running 24/7. Not on your laptop that sleeps when you close the lid. Not on a machine that reboots when Windows decides it's update time. You want it always on, always ready, always working.
Docker makes this dead simple. One configuration file, one command, and your OpenClaw agent is running in an isolated container that you can deploy anywhere β your VPS, your home server, or even a Raspberry Pi.
This guide walks you through deploying OpenClaw with Docker from scratch. No Docker experience required.
Why Docker for OpenClaw?
You can install OpenClaw directly on your system with npm install -g openclaw. That works fine for testing. But for production β where your agent runs continuously, handles real tasks, and needs to survive server reboots β Docker gives you three things raw installation doesn't:
Isolation β Your OpenClaw agent runs in its own container with its own dependencies. No conflicts with other software on your server.
Reproducibility β Your entire setup is defined in a docker-compose.yml file. Move to a new server? Copy the file, run one command, done.
Easy updates β Pull the latest image, restart the container. No dependency hell, no broken upgrades.
Prerequisites
Before we start, you need:
- A server or computer β Any Linux machine works. Ubuntu 22.04+ recommended. A $5/month VPS is plenty.
- Docker installed β We'll cover this below.
- An AI model API key β OpenAI, Anthropic, or Google. Or use Ollama for free local models.
Install Docker on Ubuntu/Debian:
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
Log out and back in, then verify:
docker --version
docker compose version
Docker Compose Setup (Step-by-Step)
Step 1: Create Your Project Directory
mkdir ~/openclaw && cd ~/openclaw
Step 2: Create docker-compose.yml
This is the heart of your Docker deployment:
version: '3.8'
services:
openclaw:
image: openclawai/openclaw:latest
container_name: openclaw
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- ./workspace:/root/.openclaw
- ./data:/data
env_file:
- .env
Step 3: Create Your .env File
Add your API keys (never commit this to git):
OPENCLAW_MODEL=anthropic/claude-sonnet-4-20250514
ANTHROPIC_API_KEY=sk-ant-your-key-here
Step 4: Initialize the Workspace
mkdir -p workspace data
docker compose run --rm openclaw openclaw init
Step 5: Start OpenClaw
docker compose up -d
That's it. Check logs with:
docker compose logs -f openclaw
Environment Variables & Configuration
Common environment variables for your .env file:
| Variable | Description | Example |
|---|---|---|
OPENCLAW_MODEL | Default AI model | anthropic/claude-sonnet-4-20250514 |
OPENAI_API_KEY | OpenAI API key | sk-... |
ANTHROPIC_API_KEY | Anthropic API key | sk-ant-... |
GOOGLE_API_KEY | Google AI API key | AIza... |
OPENCLAW_PORT | Web interface port | 3000 |
OPENCLAW_TELEGRAM_TOKEN | Telegram bot token | From @BotFather |
OPENCLAW_DISCORD_TOKEN | Discord bot token | From Discord Developer Portal |
Connect messaging platforms by adding tokens to .env and restarting:
echo "OPENCLAW_TELEGRAM_TOKEN=your-bot-token" >> .env
docker compose restart
Use Ollama for Free Local Models
Don't want to pay for API keys? Run Ollama alongside OpenClaw in Docker Compose:
version: '3.8'
services:
openclaw:
image: openclawai/openclaw:latest
container_name: openclaw
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- ./workspace:/root/.openclaw
- ./data:/data
env_file:
- .env
depends_on:
- ollama
ollama:
image: ollama/ollama:latest
container_name: ollama
restart: unless-stopped
volumes:
- ollama_data:/root/.ollama
ports:
- "11434:11434"
volumes:
ollama_data:
Update your .env:
OPENCLAW_MODEL=ollama/llama3.1
OLLAMA_HOST=http://ollama:11434
After starting, pull a model:
docker compose exec ollama ollama pull llama3.1
Now your agent runs entirely on your hardware β no API costs, full privacy.
VPS Deployment Tips
DigitalOcean β Create a $6/month droplet (1GB RAM, Ubuntu 22.04). Their one-click Docker image saves the installation step.
Hetzner β Best price-to-performance in Europe. CX22 (2 vCPU, 4GB RAM) at β¬4.35/month runs OpenClaw comfortably with room for Ollama.
Hostinger β Budget-friendly VPS starting at $5.99/month. See our dedicated Hostinger VPS guide for step-by-step setup.
Security Basics
Don't expose port 3000 to the internet:
sudo ufw allow ssh
sudo ufw allow from 127.0.0.1 to any port 3000
sudo ufw enable
For remote access, use SSH tunneling:
ssh -L 3000:localhost:3000 user@your-server
Useful Docker Commands
docker compose up -d # Start
docker compose down # Stop
docker compose logs -f openclaw # View logs
docker compose restart # Restart after config changes
docker compose pull && docker compose up -d # Update to latest
docker compose exec openclaw bash # Enter container shell
docker stats openclaw # Check resource usage
Troubleshooting Common Issues
Container won't start?
Check docker compose logs openclaw for missing API keys or port conflicts. Port 3000 in use? Change to "3001:3000" in docker-compose.yml.
Agent not responding?
- Verify container is running:
docker compose ps - Check for API errors in logs
- Ensure API key is valid and has credits
Out of disk space?
docker system prune -a
Workspace changes not persisting?
Make sure volumes are mounted correctly. The workspace/ directory should contain your AGENTS.md, SOUL.md, etc.
Ollama models downloading slowly?
Start with smaller models like llama3.1:8b for faster setup.
Frequently Asked Questions
How much RAM does OpenClaw need in Docker?
OpenClaw itself needs about 512MB. With Ollama running a 7B model, plan for 8GB total. API-only mode (no local models) runs fine on 1GB.
Can I run multiple OpenClaw agents in Docker?
Yes. Create separate services in docker-compose.yml with different container names, ports, and workspace volumes.
How do I update OpenClaw in Docker?
docker compose pull
docker compose up -d
Your workspace data persists through updates because it's stored in mounted volumes.
Is Docker required for OpenClaw?
No. You can install OpenClaw directly with npm install -g openclaw. Docker is recommended for production deployments because of isolation and easy updates.
Can I use Docker on Windows or Mac?
Yes. Install Docker Desktop for Windows or Mac, then follow the same docker-compose setup.
Want a managed VPS setup? Install OpenClaw on Hostinger VPS.
New to OpenClaw? How to Build an AI Agent.
Need skills? OpenClaw Skills Guide.
Want ready-made automation? Browse skill templates.