Docker 安装 OpenClaw

一、安装 OpenClaw

1、创建目录

bash 复制代码
mkdir -p /docker/openclaw/data
cd /docker/openclaw

2、授权

bash 复制代码
chown -R 1000:1000 data

3、创建启动脚本:start.sh

bash 复制代码
docker run -d \
  --name openclaw \
  --restart always \
  -p 18789:18789 \
  -v $(pwd)/data:/home/node/.openclaw \
  ghcr.io/openclaw/openclaw:latest \
  openclaw gateway run --allow-unconfigured

4、启动脚本

二、配置模型

1、进入容器

bash 复制代码
docker exec -it openclaw /bin/bash

2、启动向导

bash 复制代码
openclaw onboard

3、配置向导

bash 复制代码
 I understand this is personal-by-default and shared/multi-user use requires lock-down. Continue?
│  ● Yes / ○ No


 Onboarding mode
│  ● QuickStart (Configure details later via openclaw configure.)
│  ○ Manual


  Config handling
│  ● Use existing values
│  ○ Update values
│  ○ Reset


◆  Model/auth provider
│  ○ OpenAI
│  ○ Anthropic
│  ○ Chutes
│  ○ MiniMax
│  ○ Moonshot AI (Kimi K2.5)
│  ○ Google
│  ○ xAI (Grok)
│  ○ Mistral AI
│  ○ Volcano Engine
│  ○ BytePlus
│  ○ OpenRouter
│  ○ Kilo Gateway
│  ● Qwen (OAuth)
│  ○ Z.AI
│  ○ Qianfan
│  ○ Alibaba Cloud Model Studio
│  ○ Copilot
│  ○ Vercel AI Gateway
│  ○ OpenCode
│  ○ Xiaomi
│  ○ Synthetic
│  ○ Together AI
│  ○ Hugging Face
│  ○ Venice AI
│  ○ LiteLLM
│  ○ Cloudflare AI Gateway
│  ○ Custom Provider
│  ○ Ollama
│  ○ SGLang
│  ○ vLLM
│  ○ Skip for now

4、在去授权千问,把地址复制到浏览器访问

bash 复制代码
◇  Qwen OAuth ─────────────────────────────────────────────────────────────────────────╮
│                                                                                      │
│  Open https://chat.qwen.ai/authorize?user_code=LHNRC821&client=qwen-code to approve  │
│  access.                                                                             │
│  If prompted, enter the code LHNRC821.

5、授权成功

6、接着配置

bash 复制代码
◆  Default model
│  ● Keep current (qwen-portal/coder-model)
│  ○ Enter model manually
│  ○ qwen-portal/coder-model
│  ○ qwen-portal/vision-model

7、选择通道,暂时跳过

bash 复制代码
◆  Select channel (QuickStart)
│  ○ Telegram (Bot API)
│  ○ WhatsApp (QR link)
│  ○ Discord (Bot API)
│  ○ IRC (Server + Nick)
│  ○ Google Chat (Chat API)
│  ○ Slack (Socket Mode)
│  ○ Signal (signal-cli)
│  ○ iMessage (imsg)
│  ○ LINE (Messaging API)
│  ○ Feishu/Lark (飞书)
│  ○ Nostr (NIP-04 DMs)
│  ○ Microsoft Teams (Bot Framework)
│  ○ Mattermost (plugin)
│  ○ Nextcloud Talk (self-hosted)
│  ○ Matrix (plugin)
│  ○ BlueBubbles (macOS app)
│  ○ Zalo (Bot API)
│  ○ Zalo (Personal Account)
│  ○ Synology Chat (Webhook)
│  ○ Tlon (Urbit)
│  ● Skip for now

8、连网搜索,暂时跳过

bash 复制代码
◆  Search provider
│  ○ Brave Search
│  ○ Gemini (Google Search)
│  ○ Grok (xAI)
│  ○ Kimi (Moonshot)
│  ○ Perplexity Search
│  ● Skip for now 

9、配置 skills,暂时跳过

bash 复制代码
◆  Configure skills now? (recommended)
│  ○ Yes / ● No

10、启用 hooks,暂时跳过

bash 复制代码
◆  Enable hooks?
│  ◼ Skip for now
│  ◻ 🚀 boot-md
│  ◻ 📎 bootstrap-extra-files
│  ◻ 📝 command-logger
│  ◻ 💾 session-memory

11、启动Web

bash 复制代码
◆  How do you want to hatch your bot?
│  ○ Hatch in TUI (recommended)
│  ● Open the Web UI
│  ○ Do this later

三、配置 WEB 界面

1、查看 token

bash 复制代码
docker exec openclaw openclaw dashboard

2、访问

bash 复制代码
http://10.3.0.161:18789/#token=351adfbd3539293b6386f9bcd8982757d60a9075ea1445d3

3、报错一

解决方法:

1、以管理员方式进入容器,安装一些软件

bash 复制代码
docker exec -it --user root openclaw /bin/bash

2、安装软件

bash 复制代码
# debian系统更新安装包
apt-get update

# 安装 网络工具及VIM
apt-get install vim net-tools -y

3、退出容器

4、以普通用户进入容器

bash 复制代码
docker exec -it openclaw /bin/bash

5、修改配置文件

bash 复制代码
vim ~/.openclaw/openclaw.json


  "gateway": {
    "port": 18789,
    "mode": "local",
    "bind": "lan",      # 修改
    },

6、刷新访问 继续报错

origin not allowed (open the Control UI from the gateway host or allow it in gateway.controlUi.allowedOrigins)

解决:

修改配置文件

bash 复制代码
  "gateway": {
    "port": 18789,
    "mode": "local",
    "bind": "lan",
    "controlUi": {
      "allowedOrigins": [
        "http://localhost:18789",
        "http://127.0.0.1:18789",
        "http://10.3.0.161:18789"    # 加入
      ]
    },

7、刷新访问,继续报错

control ui requires device identity (use HTTPS or localhost secure context)

解决:

bash 复制代码
# 进入容器
docker exec -it openclaw /bin/bash

# 创建证书目录
mkdir -p ~/.openclaw/certs

# 生成证书(注意将CN=后面的IP替换成你的服务器IP:10.3.0.161)
openssl req -x509 -newkey rsa:4096 \
  -keyout ~/.openclaw/certs/key.pem \
  -out ~/.openclaw/certs/cert.pem \
  -days 365 -nodes \
  -subj "/C=CN/ST=Beijing/L=Beijing/O=HomeLab/CN=10.3.0.161"
  
# 编辑配置文件
vim ~/.openclaw/openclaw.json

"gateway": {
  "port": 18789,
  "bind": "lan",
  "tls": {              # 增加
    "enabled": true,
    "certFile": "/root/.openclaw/certs/cert.pem",
    "keyFile": "/root/.openclaw/certs/key.pem"
  },
  "controlUi": {
    "allowedOrigins": [
      "http://127.0.0.1:18789",
      "http://localhost:18789",
      "https://10.3.0.161:18789"    # 修改成 https
    ]
  }
}

8、查看token,加入https 重新访问

bash 复制代码
docker exec openclaw openclaw dashboard


https://10.3.0.161:18789/#token=d9056f3c91f4efa305588b1241deb1833d2576fabc494956

9、继续报错

解决

bash 复制代码
解决:
第一步:保持浏览器页面打开

第二步:在服务器上批准设备
执行以下命令(直接在宿主机,不用进容器):

bash
# 1. 查看待审批的设备列表
docker exec openclaw openclaw devices list
你会看到类似这样的输出:

text
┌──────────────────────────────────────┬──────────────┬─────────────────────┐
│ Request ID                            │ Role         │ Created At          │
├──────────────────────────────────────┼──────────────┼─────────────────────┤
│ 4f9db1bd-a1cc-4d3f-b643-2c195262464e │ browser      │ 2026-03-13 22:22:01 │
└──────────────────────────────────────┴──────────────┴─────────────────────┘
关键信息是 Request ID(第一列的那串字符)。

bash
# 2. 批准该设备(将 <request-id> 替换成上面看到的实际ID)
docker exec openclaw openclaw devices approve 4f9db1bd-a1cc-4d3f-b643-2c195262464e
如果成功,会显示 Device approved successfully 的提示 。

10、成功进入

相关推荐
神奇椰子10 小时前
[特殊字符] 服务器搭建网站完整教程
运维·服务器
慧都小妮子10 小时前
告别看图抓数据:DeviceXPlorer OPC Server 助力数据自动化管理
运维·物联网·自动化·takebishi·dxpserver·opc server
Wpa.wk10 小时前
APP自动化-Appium环境安装
运维·appium·自动化
快乐的哈士奇10 小时前
LangFuse 自托管实战:选型理由、Docker 部署与常用配置全解析
运维·人工智能·docker·容器
数智化管理手记10 小时前
精益生产3步实操,让现场从混乱变标杆
大数据·运维·网络·人工智能·精益工程
志栋智能11 小时前
超自动化巡检:为智能运维(AIOps)铺平道路
运维·安全·自动化
武汉知识图谱科技11 小时前
智慧电厂AI中台:从燃料价值链到设备知识图谱的一体化智能运维
运维·人工智能·知识图谱
墨北小七11 小时前
使用火山引擎 HiAgent 构建工业级设备智能运维智能体
运维·人工智能·火山引擎
Elecard 中国11 小时前
大规模媒体库如何实现自动化 QC?聊聊 VoD 文件检测架构
运维·自动化·ott·视频质检·vod·#视频编码·#音视频技术
weixin_4492900112 小时前
Docker + MySQL 在 Windows 11 上的本地安装部署文档
mysql·docker·容器