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、成功进入

相关推荐
姜太小白2 小时前
【Linux】麒麟V10SP3解决网络设备名不匹配问题
linux·运维·服务器
开开心心_Every2 小时前
内存清理软件灵活设置,自动阈值快捷键清
运维·服务器·pdf·web3·电脑·excel·共识算法
运维老郭2 小时前
MySQL 主从延迟根因诊断法:从现象到本质的全链路排查指南
运维·mysql
泛黄的咖啡店2 小时前
KVM 虚拟化物理机
运维
xcbeyond2 小时前
Linux 磁盘挂载
linux·运维·服务器
Dontla2 小时前
santifer/career-ops介绍(使用Claude Code自动化搜索招聘岗位并分析)(Playwright、Chromium)
运维·自动化
LoneEon2 小时前
Kubernetes高可用集群部署教程
linux·docker·kubernetes
iuu_star3 小时前
Dify网址打不开-解决方案
docker
倔强的胖蚂蚁3 小时前
AI 人工智能配置管理 Nginx
运维·nginx·云原生