DevOpsFeatured
What is OpenClaw and How to Install OpenClaw in Docker
A comprehensive guide to OpenClaw — the open-source autonomous AI agent — and a step-by-step walkthrough for installing it with Docker Compose.
April 6, 2025
·5 min read

A comprehensive guide to OpenClaw — the open-source autonomous AI agent — and a step-by-step walkthrough for installing it with Docker Compose.

OpenClaw is an open-source, autonomous AI agent that can independently perform a wide range of tasks — from processing messages and analyzing files to automating chat conversations across 50+ integrations including WhatsApp, Telegram, Slack, and Discord.
In this guide we will cover what OpenClaw is, why Docker is the recommended way to run it, and walk through the full installation step by step.
OpenClaw acts as a gateway and orchestration service that connects messengers, tools, and external services with a large language model (LLM). Depending on your configuration it can:
Because it is fully open source, you retain complete control over your data and can self-host the entire stack on your own infrastructure.
Docker Compose is the recommended and most stable installation method because:
Before you begin, make sure you have:
pnpm install may be OOM-killed on 1 GB hosts)Update your system and install required packages:
sudo apt update && sudo apt upgrade -y sudo apt install -y ca-certificates curl gnupg lsb-release
Add the Docker GPG key and repository:
sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg \ | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \ https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \ | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker Engine and Compose:
sudo apt update sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
Verify the installation:
docker --version docker compose version
git clone https://github.com/openclaw/openclaw.git cd openclaw
The repository contains the docker-compose.yml which defines the default containers:
Copy the example environment file and edit it:
cp .env.example .env nano .env
Set the key variables:
LLM_PROVIDER=anthropic ANTHROPIC_API_KEY=sk-your-api-key-here GATEWAY_TOKEN=my_secure_gateway_token MODEL_VERSION=claude-4-5-sonnet-20260101
| Variable | Purpose |
| ------------------- | ----------------------------------------------------- |
| LLM_PROVIDER | Which AI provider to use (e.g. anthropic, openai) |
| ANTHROPIC_API_KEY | Your provider API key |
| GATEWAY_TOKEN | Protects access to the dashboard |
| MODEL_VERSION | The specific model version to use |
Security tip: Restrict file permissions with
chmod 600 .envand never commit this file to version control.
The included setup script automates image building, Compose configuration, and container startup:
./scripts/docker/setup.sh
During installation you will be interactively prompted for setup options such as gateway mode, provider, and tokens.
Alternatively, you can pull the pre-built image from GitHub Container Registry:
export OPENCLAW_IMAGE="ghcr.io/openclaw/openclaw:latest" ./scripts/docker/setup.sh
docker compose up -d
Check the logs to make sure everything started correctly:
docker compose logs -f
Open your browser and navigate to:
http://127.0.0.1:18789/
You should see the OpenClaw Control UI where you can manage agents, channels, and configurations.
Verify the gateway is running:
# Liveness check curl -fsS http://127.0.0.1:18789/healthz # Readiness check curl -fsS http://127.0.0.1:18789/readyz
Connect OpenClaw to your favorite messaging platforms:
# WhatsApp (QR code based) docker compose run --rm openclaw-cli channels login # Telegram docker compose run --rm openclaw-cli channels add \ --channel telegram --token "<your-telegram-bot-token>" # Discord docker compose run --rm openclaw-cli channels add \ --channel discord --token "<your-discord-bot-token>"
| Variable | Description |
| ------------------------------ | ----------------------------------------------------- |
| OPENCLAW_IMAGE | Custom Docker image to use |
| OPENCLAW_DOCKER_APT_PACKAGES | Extra apt packages to install in the container |
| OPENCLAW_EXTRA_MOUNTS | Additional volume mounts (source:target[:opts]) |
| OPENCLAW_HOME_VOLUME | Override the /home/node volume |
| OPENCLAW_SANDBOX | Enable agent sandboxing (1, true, yes, or on) |
Pull the latest changes and rebuild:
cd openclaw git pull docker compose down docker compose build --no-cache docker compose up -d
OpenClaw provides a powerful, self-hosted AI agent platform that you can run entirely on your own infrastructure with Docker. The combination of Docker Compose isolation, persistent storage, and 50+ integrations makes it a flexible foundation for building autonomous AI workflows.
For more details, check out the official OpenClaw documentation and the GitHub repository.