OpenClaw with Docker: Deploy Your AI Agent Anywhere
February 24, 2026 · AI Tools
Running OpenClaw in Docker gives you a portable, reproducible setup that works the same on your laptop, a home server, or a cloud VPS. You get process isolation, easy upgrades by pulling a new image, and the ability to move your config and data with volumes. This guide covers the official Docker approach and how to deploy OpenClaw in a container for an always-on personal AI agent in 2026.
Why Docker for OpenClaw?
OpenClaw depends on Node.js 22 (or 20+) and runs as a long-lived process that connects to AI APIs and messaging platforms. Putting it in a container keeps your host system clean, lets you pin a specific Node and OpenClaw version, and makes it simple to run the same stack on another machine. Docker Compose can define the service, port mapping (OpenClaw’s gateway typically listens on 18789), and volumes for config and workspace so your data persists across container restarts.
For production-like or 24/7 use, a small VPS (e.g. 2 vCPU, 4GB RAM) is enough for OpenClaw in cloud API mode. Providers such as DigitalOcean, Hetzner, Vultr, or Hostinger offer Linux VPS in the $5–20/month range. Install Docker and Docker Compose on the VPS, clone or copy your Compose file and volumes, and you have an always-on agent that works even when your home connection is down.
Official Docker Setup
The OpenClaw repository includes a Docker setup. Clone the repo and use the provided script:
This typically creates two important mounts: one for the OpenClaw workspace (e.g. ~/openclaw/workspace) and one for config and state (e.g. ~/.openclaw). The gateway listens on port 18789 by default; the Compose file maps this to the host so you can run openclaw onboard from your machine if needed or use the container as a headless service.
On first run, the container may prompt you for model provider, API keys, and chat platform (Telegram, Discord, WhatsApp, Slack, etc.). You can pass these via environment variables in the Compose file so the container starts non-interactively. Check the project’s Docker documentation for the exact variable names and how to add Telegram bot tokens or Discord credentials.
Custom Dockerfile and Compose
If you prefer to build your own image, use a Node.js 22 Alpine or Debian-slim base, install OpenClaw globally with npm, and set the entrypoint to start the gateway. In Docker Compose, define a service with that image, map port 18789, mount ~/.openclaw and optionally a workspace directory, and set env vars for API keys and chat credentials. Add resource limits (memory, CPU) and a restart policy so the container restarts on failure and survives host reboots if Docker is set to start on boot.
For remote access, do not expose 18789 to the public internet unless you add authentication. Prefer SSH tunneling, a VPN, or a reverse proxy with auth so only you (or your Telegram/Discord bot traffic) can reach the gateway. If the VPS is in a region where AI APIs or messaging services are slow or blocked, run a VPN inside the container or on the host to route traffic through a stable endpoint; a VPN with high bandwidth and low latency keeps your OpenClaw responsive.
Upgrades and Maintenance
To upgrade OpenClaw when a new version is released, rebuild the image (or pull the latest if you use a pre-built image) and recreate the container. Your config and memory live in the mounted volumes, so they persist. Schedule periodic backups of ~/.openclaw so you can restore on another host if needed. Monitor container logs with docker compose logs -f to catch connection or API errors early.
GreenVPN: Stable Connectivity for Docker and VPS
When OpenClaw runs in Docker on a VPS, reliable outbound connectivity is essential. GreenVPN provides 1000Mbps gigabit bandwidth, 70+ global server locations, and 10+ years of uninterrupted operation so your containerized AI agent stays fast and available.
- ✅ 1000Mbps — no API or Telegram lag
- ✅ 70+ countries — low latency to Claude and OpenAI
- ✅ From $1.5/month — ideal for homelab and VPS
- ✅ 30-day money-back guarantee — try risk-free
- ✅ Linux-friendly — run on host or in your stack
- ✅ 10+ years stable — trusted by power users worldwide
FAQ
Can I run OpenClaw in Docker on a Mac or Windows host?
Yes. Docker Desktop on macOS and Windows runs Linux containers. Port and volume mapping work the same. For Windows, ensure the paths you mount (e.g. for .openclaw) are accessible from the Docker VM.
What is the default port for the OpenClaw gateway?
The gateway listens on 18789. Map this port in your Docker Compose or run command so you can reach it from the host or from other containers if needed.