OpenClaw AI Deployment Guide
Deploy OpenClaw agents to production environments β from a single Docker container to multi-region Kubernetes clusters on AWS, GCP, or Azure.
Choosing a Deployment Model
OpenClaw supports a spectrum of deployment targets β from a single Docker container on a $5 VPS to multi-region Kubernetes clusters with autoscaling. The right choice depends on your traffic profile, budget, team size, and compliance requirements.
| Model | Best For | Ops Overhead | Scaling |
|---|---|---|---|
| Docker Compose | Development, demos, single-server prod | Low | Manual |
| Kubernetes (Helm) | High availability, large teams | High | Horizontal auto-scale |
| AWS ECS Fargate | Serverless containers on AWS | Medium | Task-level auto-scale |
| GCP Cloud Run | Zero-to-scale, pay-per-request | Low | Automatic (0 β N) |
| Azure Container Apps | Enterprise Azure shops | Medium | KEDA-based auto-scale |
| Self-Hosted (systemd) | Air-gapped, compliance-heavy environments | High | Manual |
Production Readiness Checklist
Before going live, work through this checklist to avoid common production pitfalls:
- β Store all secrets (API keys, DB passwords) in a secrets manager β never in environment files or container images
- β
Set
OPENCLAW_LOG_LEVEL=INFOand enable JSON log format for structured log ingestion - β Configure a Prometheus scrape endpoint and set up error-rate and latency alerts
- β
Enable distributed tracing (
tracing.enabled: true) with a sampler configured for your volume - β Use a read-only filesystem for the container; mount only the required volumes
- β
Pin the agent image to a specific digest or semantic version tag β never
:latestin production - β Run a load test at β₯1.5Γ peak expected concurrency before launch
Sections
Deployment Overview
Architecture patterns, production checklist, choosing the right deployment model.
Read βDocker
Official Docker images, Dockerfile, env vars, volumes, docker-compose, and health checks.
Read βKubernetes
Helm chart, Deployment YAML, Secrets, ConfigMaps, auto-scaling, and rolling updates.
Read βAWS
ECS Fargate, Lambda, EKS, parameter store, IAM roles, and CloudWatch integration.
Read βGCP
Cloud Run, GKE, Secret Manager, Cloud Logging, and Artifact Registry.
Read βAzure
Container Apps, AKS, Key Vault, Azure Monitor, and ACR deployment.
Read βSelf-Hosted
Bare-metal, VPS, systemd services, nginx reverse proxy, and SSL setup.
Read βQuick Deploy with Docker
docker run -d \
--name openclaw \
-e OPENAI_API_KEY=sk-... \
-e OPENCLAW_PROVIDER=openai \
-v ~/.openclaw:/root/.openclaw \
-p 8080:8080 \
ghcr.io/openclaw-ai/openclaw:latestCritical Environment Variables
The following environment variables control all runtime behaviour. Set them in your container definition, Helm values.yaml, or cloud provider secrets manager β never in source code or committed files.
| Variable | Required | Example | Description |
|---|---|---|---|
OPENAI_API_KEY | Yes* | sk-β¦ | OpenAI provider key (* or Anthropic/Groq equivalent) |
OPENCLAW_PROVIDER | Yes | openai | LLM provider: openai | anthropic | groq | ollama |
OPENCLAW_MODEL | No | gpt-4o-mini | Model identifier; overrides openclaw.yaml |
OPENCLAW_LOG_LEVEL | No | INFO | DEBUG | INFO | WARNING | ERROR |
OPENCLAW_LOG_FORMAT | No | json | json for log aggregators; text for local dev |
OPENCLAW_MAX_ITERATIONS | No | 25 | Hard cap on agent think/act iterations per task |
OPENCLAW_TIMEOUT | No | 300 | Per-task timeout in seconds; 0 = unlimited |
OPENCLAW_PORT | No | 8080 | HTTP API server listen port |
OPENCLAW_METRICS_PORT | No | 9090 | Prometheus /metrics scrape port |
Production Docker Compose
For a single-server production deployment, use this hardened Docker Compose file. It adds resource limits, a health check, a non-root user, and a read-only filesystem:
version: "3.9"
services:
openclaw:
image: ghcr.io/openclaw-ai/openclaw:2.4.1 # pin to exact version
container_name: openclaw
restart: unless-stopped
read_only: true
tmpfs: [/tmp]
user: "1000:1000"
ports:
- "127.0.0.1:8080:8080" # bind to localhost only; Nginx handles TLS
- "127.0.0.1:9090:9090" # Prometheus metrics
environment:
OPENCLAW_PROVIDER: openai
OPENCLAW_LOG_FORMAT: json
OPENCLAW_LOG_LEVEL: INFO
secrets:
- openclaw_openai_key
volumes:
- openclaw_data:/root/.openclaw
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 5s
retries: 3
deploy:
resources:
limits:
cpus: "2.0"
memory: 2G
secrets:
openclaw_openai_key:
environment: OPENAI_API_KEY
volumes:
openclaw_data:Health & Readiness Endpoints
OpenClaw exposes two HTTP endpoints for container orchestrators and load balancers:
| Path | Method | Success Response | Use In |
|---|---|---|---|
/health | GET | 200 {"status":"ok"} | Docker HEALTHCHECK, K8s livenessProbe |
/ready | GET | 200 {"ready":true} | K8s readinessProbe; fails until LLM provider reachable |
/metrics | GET | Prometheus text format | Prometheus scrape job on port 9090 |
Networking & Reverse Proxy
Always place OpenClaw behind a TLS-terminating reverse proxy in production. Below is a minimal Nginx configuration with rate-limiting:
upstream openclaw {
server 127.0.0.1:8080;
keepalive 16;
}
server {
listen 443 ssl http2;
server_name agents.example.com;
ssl_certificate /etc/letsencrypt/live/agents.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/agents.example.com/privkey.pem;
limit_req_zone $binary_remote_addr zone=api:10m rate=30r/m;
limit_req zone=api burst=10 nodelay;
location / {
proxy_pass http://openclaw;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 300s; # long-running agents need extended timeout
}
}Horizontal Scaling Strategies
OpenClaw agents are stateless by design β all persistent state is stored externally (Redis for short-term memory, PostgreSQL or Pinecone for long-term memory). This makes horizontal scaling straightforward:
- Docker Swarm / ECS: Scale the service replica count; use an Application Load Balancer to distribute incoming task requests.
- Kubernetes HPA: Autoscale on
openclaw_agent_active(custom metric via Prometheus Adapter) or CPU/memory. A target of 70% concurrent agent capacity works well as an initial threshold. - Queue-based scaling: Decouple task submission (HTTP) from execution (workers) using RabbitMQ or AWS SQS. Scale workers independently from the API layer.
- Read replicas: If using PostgreSQL for memory, add read replicas for memory retrieval queries to reduce load on the primary.
Secrets Management
Never store API keys in environment files, container images, or source code. Use these provider-native secrets managers:
| Platform | Service | OpenClaw Integration |
|---|---|---|
| AWS | AWS Secrets Manager / Parameter Store | Set secrets_provider: aws_ssm in openclaw.yaml |
| GCP | Secret Manager | Set secrets_provider: gcp_secretmanager |
| Azure | Key Vault | Set secrets_provider: azure_keyvault |
| Kubernetes | K8s Secrets + Sealed Secrets / ESO | Mount as env vars or volume; rotate via ESO sync |
| Self-hosted | HashiCorp Vault | Set secrets_provider: vault with AppRole auth |
Zero-Downtime Upgrades
To upgrade OpenClaw without dropping in-flight agent tasks:
- Put new version in maintenance tag (e.g.,
:2.5.0-rc1) alongside current:2.4.1. - Use a blue/green deployment: route 5% of traffic to new version, monitor error rates in Grafana for 15 minutes.
- Enable
drain_timeout: 300inopenclaw.yamlβ running agents complete before the pod terminates. - Shift traffic to 100% once error rate is stable; decommission old pods.
- Run
openclaw db migrateafter all pods are on new version if a schema migration is pending.