Kritsana.prs

ChangelogContactResume

© Copyright 2026 Kritsana.Dev. All rights reserved.

Back to Blog
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
What is OpenClaw and How to Install OpenClaw in Docker

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.

What is OpenClaw?

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:

  • Manage calendars and handle files
  • Send notifications and trigger automations
  • Execute developer workflows end-to-end
  • Integrate with WhatsApp, Telegram, Discord, Slack, and many more

Because it is fully open source, you retain complete control over your data and can self-host the entire stack on your own infrastructure.

Why Run OpenClaw with Docker?

Docker Compose is the recommended and most stable installation method because:

  • All dependencies are automatically managed in isolation
  • Updates and extensions are straightforward
  • The gateway, CLI, and optional sandbox each run in their own container
  • Persistent volumes keep your data safe across restarts

Prerequisites

Before you begin, make sure you have:

  • Docker Desktop (or Docker Engine) + Docker Compose v2
  • At least 2 GB RAM for the image build (pnpm install may be OOM-killed on 1 GB hosts)
  • Sufficient disk space for images and logs
  • A Linux server (Ubuntu recommended) or local machine
  • An API key from an LLM provider (e.g. Anthropic, OpenAI)

Step 1 — Install Docker and Docker Compose

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

Step 2 — Clone the OpenClaw Repository

git clone https://github.com/openclaw/openclaw.git
cd openclaw

The repository contains the docker-compose.yml which defines the default containers:

  • openclaw-gateway — the main service that starts OpenClaw
  • openclaw-cli — the command-line tool for configuration and channel management

Step 3 — Configure Environment Variables

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 .env and never commit this file to version control.

Step 4 — Run the Setup Script

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

Step 5 — Start Docker Compose

docker compose up -d

Check the logs to make sure everything started correctly:

docker compose logs -f

Step 6 — Access the Web Interface

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.

Step 7 — Health Checks

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

Optional — Configure Messaging Channels

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>"

Key Environment Variables Reference

| 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) |

Keeping OpenClaw Up to Date

Pull the latest changes and rebuild:

cd openclaw
git pull
docker compose down
docker compose build --no-cache
docker compose up -d

Wrapping Up

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.