How to Run OpenClaw in Docker: Complete Container Guide
Hosting & Deployment ยท 13 min read
How to Run OpenClaw 24/7 with Docker (Step-by-Step)
Last updated: February 2026 ยท Reading time: 10 minutes ยท Difficulty: Intermediate
Docker is the cleanest way to run OpenClaw on a server. Everything lives inside a container โ your config, your dependencies, your assistant. If something breaks, you tear it down and start fresh in seconds. If you want to move to a different server, you copy one folder and run one command.
This guide assumes you've never used Docker before. By the end, you'll have OpenClaw running in a Docker container on a cloud server, responding to your messages 24/7, and automatically restarting itself if anything crashes.
Why Docker?
You can install OpenClaw directly on a server with npm install -g openclaw@latest. That works fine. But Docker gives you a few things that bare-metal installs don't.
Isolation. OpenClaw runs in its own sandbox. It can't accidentally mess with other things running on your server, and nothing else can mess with it.
Reproducibility. Your setup is defined in a file. If your server dies tomorrow, you spin up a new one, copy your config, run docker-compose up, and you're back online in minutes.
Easy updates. Pull the new image, restart the container. No dependency conflicts, no version mismatches, no "it worked on my machine" problems.
Sandboxed tool execution. OpenClaw can run bash commands and browser automation. Docker means those tools run inside the container, not loose on your server. That's a meaningful security improvement.
If none of that matters to you and you just want the simplest path, use the standard setup guide instead. Docker adds a layer of complexity that not everyone needs.
What You'll Need
A cloud server with at least 1 GB of RAM (2 GB recommended). Any Linux distribution works, but Ubuntu 22.04 or 24.04 is easiest.
If you don't have a server yet, grab one from DigitalOcean ($200 free credit for new accounts) or Hetzner (โฌ3.79/month for their ARM server). Both work perfectly for this.
โ Get $200 free credit on DigitalOcean โ Sign up for Hetzner Cloud
An AI API key from Anthropic or OpenAI. Get one at console.anthropic.com if you haven't already.
A messaging account โ Telegram is easiest for Docker setups since it only needs a bot token (no QR code scanning required).
Step 1: Set Up Your Server
SSH into your fresh server. If you're on DigitalOcean or Hetzner, you got the IP address and credentials when you created it.
ssh root@your-server-ip
First, update everything:
apt update && apt upgrade -y
[IMAGE: Screenshot of terminal showing SSH connection to a fresh server]
Step 2: Install Docker
Ubuntu makes this straightforward. Run these commands one at a time:
# Install Docker
curl -fsSL https://get.docker.com | sh
# Install Docker Compose plugin
apt install docker-compose-plugin -y
# Verify it worked
docker --version
docker compose version
You should see version numbers for both. If you do, Docker is ready.
[IMAGE: Screenshot showing successful Docker and Docker Compose installation with version numbers]
Step 3: Create Your OpenClaw Directory
Make a dedicated folder for everything OpenClaw-related:
mkdir -p /opt/openclaw
cd /opt/openclaw
This is where your configuration, data, and Docker files will live. Using /opt/openclaw keeps things organized and separate from the rest of your system.
Step 4: Create the Docker Compose File
This is the file that tells Docker how to run OpenClaw. Create it with:
nano docker-compose.yml
Paste in the following:
version: "3.8"
services:
openclaw:
image: ghcr.io/openclaw/openclaw:latest
container_name: openclaw
restart: unless-stopped
ports:
- "18789:18789"
volumes:
- ./data:/root/.openclaw
env_file:
- .env
environment:
- NODE_ENV=production
Save and exit (Ctrl+X, then Y, then Enter in nano).
Here's what each line does:
- image โ Pulls the official OpenClaw Docker image from GitHub's container registry.
- restart: unless-stopped โ If OpenClaw crashes or your server reboots, Docker automatically restarts it. This is what gives you the 24/7 reliability.
- ports โ Exposes the gateway dashboard on port 18789 so you can access it from your browser.
- volumes โ Maps a local
datafolder to OpenClaw's config directory inside the container. This means your configuration persists even if you destroy and recreate the container. - env_file โ Loads your API keys and tokens from a separate
.envfile so they're not hardcoded anywhere.
Step 5: Create Your Environment File
The .env file holds your secrets โ API keys and bot tokens. Create it:
nano .env
Add your credentials:
# AI Model (pick one or both)
ANTHROPIC_API_KEY=sk-ant-your-key-here
# Messaging channels (add whichever you use)
TELEGRAM_BOT_TOKEN=123456789:ABCDefGHIjklMNOpqrSTUvwxYZ
# Optional: OpenAI as fallback
# OPENAI_API_KEY=sk-your-key-here
Save and exit. Then lock down the file permissions so only root can read it:
chmod 600 .env
This is important. Your API keys are essentially passwords โ anyone who has them can use your AI credits and access your messaging channels.
[IMAGE: Screenshot showing the .env file being created (with redacted/example keys, not real ones)]
Step 6: Create Your OpenClaw Config
Create the data directory and config file:
mkdir -p data
nano data/openclaw.json
Paste in a starter configuration:
{
"agent": {
"model": "anthropic/claude-sonnet-4-5"
},
"channels": {
"telegram": {
"botToken": "${TELEGRAM_BOT_TOKEN}"
}
},
"gateway": {
"port": 18789
}
}
This is a minimal config that gets you running. You can always add more channels, change models, or enable additional features later.
For WhatsApp, the setup is slightly different since it requires QR code scanning. You'll need to run the pairing process first โ see the "Adding WhatsApp" section below.
Step 7: Start OpenClaw
Everything is in place. Start it up:
docker compose up -d
The -d flag runs it in detached mode โ in the background, so it keeps running after you close your terminal.
The first time takes a minute or two as Docker downloads the OpenClaw image. After that, startups take a few seconds.
Check that it's running:
docker compose logs -f
You should see OpenClaw's startup logs scrolling by โ gateway initialization, channel connections, model configuration. Look for a line that says something like "Gateway listening on port 18789" and your Telegram channel connecting successfully.
Press Ctrl+C to stop watching logs (the container keeps running).
[IMAGE: Screenshot of terminal showing docker compose up and the subsequent logs showing successful startup]
Step 8: Test It
Open Telegram and message your bot. You should get a response within a few seconds.
If it works โ you're done. Your AI assistant is running in Docker, will survive server reboots, and will automatically restart if it crashes.
[IMAGE: Screenshot of Telegram conversation showing a successful first message with the Dockerized assistant]
Managing Your Container
A few commands you'll use regularly.
View logs:
docker compose logs -f
Add --tail 100 to see just the last 100 lines instead of the full history.
Restart OpenClaw:
docker compose restart
Stop OpenClaw:
docker compose down
Update to the latest version:
docker compose pull
docker compose up -d
That's it โ two commands to update. Docker pulls the newest image and recreates the container with your existing config and data intact.
Check resource usage:
docker stats openclaw
This shows real-time CPU, memory, and network usage. OpenClaw typically sits at 50โ150 MB of RAM when idle and barely touches the CPU until you send a message.
Adding WhatsApp to a Docker Setup
WhatsApp is trickier with Docker because it requires scanning a QR code to link your device. You can't do that headlessly the first time.
Here's the workaround:
# Run the channel login interactively
docker compose exec openclaw openclaw channels login
A QR code appears in your terminal. Scan it with WhatsApp on your phone (Settings โ Linked Devices โ Link a Device).
Once paired, the session is saved in your data folder and persists across container restarts. You only need to scan the code once โ unless the link expires from extended downtime.
Then update your openclaw.json to add the WhatsApp channel:
{
"channels": {
"telegram": {
"botToken": "${TELEGRAM_BOT_TOKEN}"
},
"whatsapp": {
"allowFrom": ["+1234567890"]
}
}
}
Restart the container:
docker compose restart
Enabling Browser Tools
One of OpenClaw's most powerful features is browser control โ your assistant can navigate websites, fill forms, and extract information. Docker actually makes this safer because the browser runs inside the container.
OpenClaw provides a separate Docker image for browser-enabled setups. Update your docker-compose.yml:
version: "3.8"
services:
openclaw:
image: ghcr.io/openclaw/openclaw:latest
container_name: openclaw
restart: unless-stopped
ports:
- "18789:18789"
volumes:
- ./data:/root/.openclaw
env_file:
- .env
environment:
- NODE_ENV=production
openclaw-browser:
image: ghcr.io/openclaw/openclaw-sandbox-browser:latest
container_name: openclaw-browser
restart: unless-stopped
network_mode: "service:openclaw"
Then enable browser tools in your config:
{
"browser": {
"enabled": true
}
}
Restart everything:
docker compose up -d
Your assistant can now browse the web on your behalf.
Setting Up Automatic Backups
Your entire OpenClaw setup lives in the /opt/openclaw/data folder. Back that up and you can restore your assistant โ complete with conversation history, configs, and channel sessions โ on any server.
A simple daily backup script:
nano /opt/openclaw/backup.sh
#!/bin/bash
DATE=$(date +%Y%m%d)
tar -czf /opt/openclaw/backups/openclaw-$DATE.tar.gz -C /opt/openclaw data/
# Keep only last 7 days
find /opt/openclaw/backups/ -name "*.tar.gz" -mtime +7 -delete
Make it executable and schedule it:
chmod +x /opt/openclaw/backup.sh
mkdir -p /opt/openclaw/backups
# Run daily at 3am
crontab -e
# Add this line:
0 3 * * * /opt/openclaw/backup.sh
If you ever need to migrate to a new server, copy the data folder and your docker-compose.yml and .env files. That's your entire setup.
Securing Your Docker Setup
A few things to do before walking away from your setup.
Keep the gateway port local. If you don't need to access the dashboard remotely, remove the ports mapping from your Docker Compose file entirely. The assistant still works through messaging channels without it.
If you do need remote dashboard access, use Tailscale instead of exposing port 18789 to the internet. Tailscale is free for personal use and creates a private encrypted tunnel to your server.
Run the health check:
docker compose exec openclaw openclaw doctor
This scans your configuration for security issues โ open DM policies, exposed services, misconfigured permissions. Fix anything it flags.
Keep Docker updated:
apt update && apt upgrade -y
Run this periodically. Docker and your server's OS both receive security patches that matter.
Troubleshooting
Container won't start
Check the logs:
docker compose logs openclaw
The most common cause is a malformed openclaw.json. Validate your JSON at jsonlint.com if you're not sure.
"Permission denied" errors
If you see permission issues with the data volume, fix ownership:
chown -R 1000:1000 /opt/openclaw/data
Container runs but bot doesn't respond
Check that your API key and bot token are correct in the .env file. Try regenerating your Telegram bot token through BotFather if the old one stopped working.
High memory usage
If the container is eating more RAM than expected, your conversation context might be getting long. Send /compact in your chat to trim it down, or /new to start a fresh session.
Docker Compose version mismatch
If docker compose (without hyphen) doesn't work, you might have the older standalone version. Try docker-compose (with hyphen) instead, or install the plugin:
apt install docker-compose-plugin -y
Frequently Asked Questions
Can I run OpenClaw alongside other Docker containers?
Yes. OpenClaw is lightweight โ typically 50โ150 MB of RAM when idle. A 2 GB server can comfortably run OpenClaw alongside things like Nginx, a database, or other small services.
Do I need Docker Desktop?
No. Docker Desktop is for Mac and Windows. On a Linux server, you just need Docker Engine and the Compose plugin, which is what we installed in Step 2.
How do I check my API spending?
Send /status to your assistant in any channel. It shows current session info including token usage and costs. For overall spending, check your Anthropic dashboard at console.anthropic.com.
Can I use Podman instead of Docker?
OpenClaw does support Podman. There's a openclaw.podman.env file in the repository. The setup is similar but with some differences in networking and volume handling. If you're already a Podman user, check the official docs for the Podman-specific instructions.
What happens to my data if I delete the container?
Nothing โ your data lives in the ./data volume on your host machine, not inside the container. You can delete, recreate, and update the container as many times as you want without losing your configuration, conversation history, or channel sessions.
New to cloud servers? Start with our hosting comparison to pick the right provider, or check the full cost breakdown to understand what you'll spend. For the non-Docker path, see our standard setup guide.