raspbian
deepin
2026-03-13 09:53 你确定这不是AI通过幻觉写出来的教程?
Reply Like 0 View the author
你确定这不是AI通过幻觉写出来的教程?
你确定这不是AI通过幻觉写出来的教程?
一字一句自己码出来的,如假包换。
一字一句自己码出来的,如假包换。
我能证明这就是自己写的
下面这才是Ai写的
你记录的笔记核心流程正确,我帮你梳理成更清晰、避坑的完整步骤,并修正笔记中少量笔误 / 易踩坑点:
# 确认Docker和Docker Compose已安装(Debian 13.3默认可能需要手动装)
docker --version # 需显示29.3.0+
docker compose version # 确保是v2+版本(v1已废弃)
# 创建目录(层级更清晰,避免路径问题)
mkdir -p ~/docker-compose/openclaw
cd ~/docker-compose/openclaw # 后续所有compose命令必须在此执行
# 下载官方配置文件(如果wget失败,可换curl或手动复制内容)
wget https://raw.githubusercontent.com/openclaw/openclaw/main/docker-compose.yml
wget https://raw.githubusercontent.com/openclaw/openclaw/main/.env.example
# 备用方案(国内访问GitHub失败时):
# curl -o docker-compose.yml https://raw.githubusercontent.com/openclaw/openclaw/main/docker-compose.yml
# curl -o .env.example https://raw.githubusercontent.com/openclaw/openclaw/main/.env.example
# 笔记笔误修正:原命令是cp .env.example.yml .env(错误),正确如下
cp .env.example .env
# 生成随机Token(关键:用于网关认证)
TOKEN=$(openssl rand -hex 32)
# 编辑.env文件(用nano更友好)
nano .env
在.env 中修改以下内容(其他默认即可):
ini
OPENCLAW_IMAGE=ghcr.io/openclaw/openclaw:latest
OPENCLAW_CONFIG_DIR=~/.openclaw
OPENCLAW_WORKSPACE_DIR=~/.openclaw/workspace
OPENCLAW_GATEWAY_TOKEN=${TOKEN} # 直接填入上面生成的随机串,或手动写
保存退出:Ctrl+O → 回车 → Ctrl+X
nano docker-compose.yml
找到 services.openclaw-gateway或 openclaw-cli的配置块,在 volumes/ports同级添加 DNS 配置(国内必须加,否则插件安装 / 模型验证失败):
yaml
services:
openclaw-gateway:
image: ${OPENCLAW_IMAGE}
volumes:
- ${OPENCLAW_CONFIG_DIR}:/root/.openclaw
- ${OPENCLAW_WORKSPACE_DIR}:/root/.openclaw/workspace
ports:
- "18789:18789"
dns: # 新增DNS配置(与volumes/ports对齐)
- 114.114.114.114
- 223.5.5.5
command: ["gateway", "start"]
openclaw-cli:
image: ${OPENCLAW_IMAGE}
volumes:
- ${OPENCLAW_CONFIG_DIR}:/root/.openclaw
- ${OPENCLAW_WORKSPACE_DIR}:/root/.openclaw/workspace
dns: # CLI也加DNS,避免插件安装失败
- 114.114.114.114
- 223.5.5.5
stdin_open: true
tty: true
# 提前创建目录,并确保属主是当前用户(不是root)
mkdir -p ~/.openclaw/workspace
chown -R $USER:$USER ~/.openclaw # 关键:避免容器内无法写入
# 启动安装向导(必须带--env-file,否则变量不生效)
docker compose --env-file .env run --rm openclaw-cli onboard
向导内配置(以 DeepSeek 为例):
Custom (OpenAI Compatible)https://api.deepseek.com/v1deepseek-chat 或 deepseek-reasonerskip now若出现「模型 verification failed」:
# 修改bind模式(默认loopback仅本地访问,lan允许局域网)
nano ~/.openclaw/openclaw.json
# 找到 "bind": "loopback" → 修改为 "bind": "lan"
# 重启向导
docker compose down # 清理旧容器
docker compose --env-file .env run --rm openclaw-cli onboard
docker compose --env-file .env up -d openclaw-gateway # 后台启动
# 验证服务是否启动
docker compose ps # 查看openclaw-gateway状态为Up
若 127.0.0.1:18789 无法访问:
# 再次检查bind配置
nano ~/.openclaw/openclaw.json # 确保"bind": "lan"
# 进入容器重启网关
docker compose exec openclaw-gateway bash
openclaw gateway restart
exit # 退出容器
http://127.0.0.1:18789/OPENCLAW_GATEWAY_TOKEN# 进入容器
docker compose exec openclaw-gateway bash
# 查看待配对设备
openclaw devices list # 找到Pending状态的设备,记录RequestID(如xxxx-xxxx-xxxx)
# 批准配对
openclaw devices approve xxxx-xxxx-xxxx
# 验证配对状态(应为Paired)
openclaw devices list
exit
docker compose exec openclaw-gateway bash
openclaw configure # 按需修改模型、端口、日志等配置
openclaw gateway restart # 重启生效
exit
# 方式1:CLI命令
docker compose run --rm openclaw-cli channels add --channel 渠道名 --token "认证信息"
# 方式2:交互式配置
docker compose run --rm openclaw-cli configure
# 1. 进入容器(必须在容器内执行插件安装)
docker compose exec openclaw-gateway bash
# 2. 安装QQBot插件(DNS已配置,避免解析失败)
openclaw plugins install @sliverp/qqbot@latest
# 3. 添加QQ渠道(替换为自己的AppID和AppSecret)
openclaw channels add --channel qqbot --token "你的AppID:你的AppSecret"
# 4. 重启网关
openclaw gateway restart
exit
~/.openclaw并设置属主为当前用户,否则容器内会以 root 创建目录,导致写入权限不足;loopback仅允许容器内访问,修改为 lan才能通过宿主机 IP 访问 18789 端口;cp .env.example.yml .env是错误的,正确是 cp .env.example .env(无.yml 后缀);openssl rand -hex 32生成足够长的随机串,避免弱口令。# 查看日志(排障用)
docker compose logs -f openclaw-gateway
# 停止服务
docker compose down
# 重启服务
docker compose --env-file .env restart openclaw-gateway
# 更新OpenClaw版本
docker compose pull openclaw-gateway
docker compose --env-file .env up -d openclaw-gateway
docker compose logs)、检查端口映射、确认 Token 和 bind 配置。Popular Ranking
ChangePopular Events
More