养虾指南
OpenClaw System Guide
Recommended

Install OpenClaw with Docker

Cross-platform universal method for most users. Pull image with one command, manage with docker-compose, deploy in 10 minutes.

Docker is the simplest and most recommended way to deploy OpenClaw. No need to manually install Node.js or any dependencies — one command to start. Works on Mac, Windows, and Linux. The environment is fully isolated, making upgrades and backups effortless. For beginners, Docker avoids many pitfalls of source code installation.

Prerequisites

  • Docker Desktop (Mac/Windows) or Docker Engine (Linux) installed
  • At least 2GB available memory
  • At least one LLM API key (OpenAI / Anthropic / DeepSeek / Qwen, etc.)
Don't have Docker yet? Visit docker.com/get-started to download Docker Desktop. After installation, make sure Docker is running (whale icon in system tray). Docker Desktop is free for personal use. Linux users should use Docker Engine + Docker Compose plugin.
1

Pull the OpenClaw Image

Open your terminal (Mac/Linux) or PowerShell (Windows) and pull the latest OpenClaw Docker image:

Terminal
docker pull openclaw/openclaw:latest
Users in China can configure Docker mirror accelerators (available free from Alibaba Cloud, Tencent Cloud, etc.) for faster pulls. Open Docker Desktop → Settings → Docker Engine, add registry-mirrors.
2

Create Project Directory and docker-compose.yml

Create a new directory to hold OpenClaw configuration files:

Terminal
mkdir openclaw && cd openclaw

Create a docker-compose.yml file in that directory with the following content:

docker-compose.yml
version: "3.8"

services:
  openclaw:
    image: openclaw/openclaw:latest
    container_name: openclaw
    restart: unless-stopped
    ports:
      - "3210:3210"
    volumes:
      - openclaw_data:/app/data
    env_file:
      - .env
    environment:
      - NODE_ENV=production

volumes:
  openclaw_data:
The docker-compose.yml defines the OpenClaw service: port mapping (3210), data persistence (volumes), auto-restart policy, etc. Data is persisted via Docker volumes and survives upgrades.
3

Configure Environment Variables (.env file)

Create a .env file in the same directory with your API keys and runtime configuration. This is the most critical configuration step:

.env
# OpenClaw 环境变量配置
# 大模型 API 密钥(必填,至少配置一个)

# Option 1: OpenAI / GPT
OPENAI_API_KEY=sk-your-openai-api-key
OPENAI_MODEL=gpt-4o

# Option 2: Claude
# ANTHROPIC_API_KEY=sk-ant-your-key
# ANTHROPIC_MODEL=claude-sonnet-4-20250514

# Option 3: DeepSeek(国产,性价比高)
# DEEPSEEK_API_KEY=your-deepseek-key
# DEEPSEEK_MODEL=deepseek-chat

# 访问密码(强烈建议设置)
ACCESS_CODE=your-secure-password

# 端口(默认 3210)
PORT=3210
Always set ACCESS_CODE! Without an access password, anyone who knows your IP can access your OpenClaw instance and consume your API credits. This is not optional — it's essential.
Not sure which model? DeepSeek offers the best value, Claude is most capable overall, and GPT-4o is the most versatile. You can configure multiple API keys and switch between them in the OpenClaw UI.
4

Start OpenClaw

Start OpenClaw with a single command (-d for background mode):

Terminal
docker compose up -d

On first run, the image will be pulled automatically if not done earlier. Check status and logs with:

Terminal
# 查看容器状态
docker compose ps

# 查看实时日志
docker compose logs -f openclaw
5

Access the Web UI

Open your browser and navigate to:

Browser
http://localhost:3210
If you see the OpenClaw login/main interface, congratulations — installation is complete! Enter the ACCESS_CODE from your .env to log in. You can now configure your first AI Agent.

Useful Management Commands

Commands
# 停止 OpenClaw
docker compose stop

# 重新启动
docker compose restart

# 更新到最新版本
docker compose pull && docker compose up -d

# 查看日志
docker compose logs -f openclaw

# 完全删除(数据保留在 volume 中)
docker compose down

Troubleshooting

Port 3210 is already in use

Change the port mapping in docker-compose.yml from "3210:3210" to "3211:3210", then access via http://localhost:3211.

Container exits immediately after starting

Run docker compose logs openclaw to check error logs. Common causes: malformed .env file (no spaces around =), invalid API key, insufficient memory (2GB minimum).

Image pull timeout or very slow

Network issues in certain regions. Configure Docker mirror accelerators via Docker Desktop → Settings → Docker Engine.

How to update to the latest version

Run docker compose pull && docker compose up -d. Data persists via Docker volumes — nothing is lost during updates.

How to back up data

Data is in Docker volume openclaw_data. Export with: docker run --rm -v openclaw_data:/data -v $(pwd):/backup busybox tar czf /backup/openclaw-backup.tar.gz /data

Installed! Next: Feed Your Agent

Your agent is installed but can't think or talk yet — configure an LLM API and messaging tool to bring it alive.

Feed Your Agent