下面是你提供内容整理后的 Markdown(MD)格式版本,已经结构化并优化排版,适合直接放到文档或博客中使用 👇


🐳 Docker 部署 OpenClaw 完整教程

📋 目录


一、OpenClaw 简介

1.1 什么是 OpenClaw?

OpenClaw 是一个开源个人 AI 助手平台,支持通过 WhatsApp、Telegram、Discord 等聊天工具与 AI 交互,可用于处理邮件、日历、文件等任务。

1.2 汉化版特色

  • ✅ 全中文界面(CLI + Dashboard)
  • 🔄 每小时自动同步
  • 🌐 多平台支持(WhatsApp / Telegram / Discord)
  • 🔌 丰富插件(1Password、Apple Notes 等)

1.3 为什么选择 Docker 部署?

  • 环境隔离,避免依赖冲突
  • 快速部署,开箱即用
  • 易于迁移和备份
  • 国内镜像加速拉取

二、部署架构图

2.1 系统架构

📱 用户访问层
  ├─ WhatsApp / Telegram / Discord / 浏览器

🐳 Docker 容器层
  ├─ OpenClaw 网关服务 (18789)
  ├─ AI 模型连接(Claude / ChatGPT / Ollama)
  ├─ 聊天平台适配器
  └─ 插件系统

💾 数据持久层
  └─ Docker Volume: openclaw-data → /root/.openclaw

2.2 部署流程

阶段 操作
1️⃣ 安装 Docker
2️⃣ 初始化配置
3️⃣ 启动服务
4️⃣ 访问使用

三、环境准备

3.1 系统要求

  • Linux / macOS / Windows
  • 已安装 Docker

3.2 安装 Docker

Ubuntu / Debian

# 官方脚本(推荐)
curl -fsSL https://get.docker.com | bash

# 国内镜像
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

CentOS / RHEL

curl -fsSL https://get.docker.com | bash

验证安装

docker --version
sudo systemctl status docker

添加用户权限(可选)

sudo usermod -aG docker $USER
newgrp docker

3.3 拉取镜像

# 国内(推荐)
docker pull 1186258278/openclaw-zh:latest

# 海外
docker pull ghcr.io/1186258278/openclaw-zh:latest

验证:

docker images | grep openclaw

四、快速部署(一键脚本)

Linux / macOS

# 国内
curl -fsSL https://cdn.jsdelivr.net/gh/1186258278/OpenClawChineseTranslation@main/docker-deploy.sh | bash -s -- --china

# 海外
curl -fsSL https://cdn.jsdelivr.net/gh/1186258278/OpenClawChineseTranslation@main/docker-deploy.sh | bash -s

Windows(PowerShell)

irm https://cdn.jsdelivr.net/gh/1186258278/OpenClawChineseTranslation@main/docker-deploy.ps1 | iex

五、手动部署(完整流程)

5.1 初始化配置

IMAGE=1186258278/openclaw-zh:latest

docker run --rm -it \
  -v openclaw-data:/root/.openclaw \
  $IMAGE \
  openclaw onboard

5.2 设置网关模式

# 本地访问
docker run --rm -v openclaw-data:/root/.openclaw $IMAGE \
  openclaw config set gateway.mode local

# 局域网访问
docker run --rm -v openclaw-data:/root/.openclaw $IMAGE \
  openclaw config set gateway.mode lan

5.3 启动服务

docker run -d \
  --name openclaw \
  -p 18789:18789 \
  -v openclaw-data:/root/.openclaw \
  --restart unless-stopped \
  $IMAGE \
  openclaw gateway run

5.4 验证运行

docker ps | grep openclaw
docker logs openclaw

访问:


六、配置详解

6.1 AI 模型配置

Claude

openclaw config set llm.model "claude-3.5-sonnet"
openclaw config set llm.apiKey "your-key"

GPT

openclaw config set llm.model "gpt-4o"
openclaw config set llm.apiKey "your-key"

Ollama

openclaw config set llm.model "ollama/llama3.2"
openclaw config set llm.baseURL "http://host.docker.internal:11434/v1"

6.2 网络模式

模式 说明
local 仅本机
lan 局域网

6.3 安全配置

openclaw config set gateway.controlUi.dangerouslyDisableDeviceAuth true
docker restart openclaw

⚠️ 注意:建议生产环境使用 HTTPS + 防火墙


七、常见问题与解决方案

7.1 容器退出

docker logs openclaw
docker inspect openclaw

解决:

docker rm -f openclaw

7.2 无法访问 Dashboard

检查:

docker ps

开放端口:

sudo ufw allow 18789/tcp

7.3 API Key 错误

openclaw config get llm.apiKey

7.4 数据备份

docker run --rm -v openclaw-data:/data -v $(pwd):/backup \
  ubuntu tar czf /backup/backup.tar.gz /data

八、进阶配置

8.1 Docker Compose

version: '3.8'

services:
  openclaw:
    image: 1186258278/openclaw-zh:latest
    container_name: openclaw
    ports:
      - "18789:18789"
    volumes:
      - openclaw-data:/root/.openclaw
    restart: unless-stopped
    command: openclaw gateway run

volumes:
  openclaw-data:

启动:

docker-compose up -d

8.2 Nginx + HTTPS

server {
    listen 80;
    server_name your-domain.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name your-domain.com;

    location / {
        proxy_pass http://localhost:18789;
    }
}

8.3 资源限制

--memory="2g"
--cpus="2.0"

九、运维管理

常用命令

docker start openclaw
docker stop openclaw
docker restart openclaw
docker logs -f openclaw

更新版本

docker pull 1186258278/openclaw-zh:latest

完全卸载

docker rm -f openclaw
docker volume rm openclaw-data
docker rmi 1186258278/openclaw-zh:latest

📚 参考资源


如果你需要,我可以帮你👇

  • ✅ 转成 Notion / 飞书文档格式
  • ✅ 精简成「一页速查版」
  • ✅ 或做成 可直接运行的 docker-compose 完整生产方案(含 HTTPS + 域名)