首先需要确定使用方式,这决定了你用什么方式部署。先通过 README.md 整体了解一下这个项目:https://github.com/openclaw/openclaw/blob/main/README.md
通过阅读文档,我们知道 OpenClaw 可以跑在本地宿主机、虚拟机、云服务器等载体上,如何和它对话呢?
它支持非常多的渠道,我选择了 Telegram。因为小龙虾的能力上限取决于模型能力,所以毋庸置疑,直接选择当前的顶级模型,Claude 或者 GPT,那结论就出来了,最佳配置方案:海外云 VPS + Telegram + 顶级模型。
openclaw docker 教程
先阅读一下部署文档再动手:https://github.com/openclaw/openclaw/blob/main/docs/install/docker.md
git clone https://github.com/openclaw/openclaw.gitcd openclaw ./docker-setup.sh
运行脚本后,会在宿主机上创建两个重要文件夹,它们会被挂载到 Docker 容器中:
① — 配置目录
② — 工作空间目录

先选择 Skip for now 跳过

消息渠道我想用 Telegram,所以需要先做两件事:

然后就是一路跳过,hooks 这里选择:
等出现了 Token 提示,说明配置完成:
Token:
大功告成。浏览器访问 ,但是这里最好用域名来访问,在 5.2 节 有说明。
然后就是在服务器上执行配对命令:
# 宿主机直接执行openclaw pairing approve telegram YKEY9974# Docker 版执行方式docker compose run --rm openclaw-cli pairing approve telegram YKEY9974
注意: 配对码默认 1 小时过期,每个渠道待处理请求默认上限 3 个。执行命令的时候如果过期,日志会提示:
[openclaw] Failed to start CLI: Error: No pending pairing request found for code: 8AGF3F58
这个需要重新在 Telegram 发送机器人 获取新配对码。
配对成功:

这里很多人都会纠结,模型我对比了很多家。只需要从两个角度来考虑:
推荐去 ClawHub 社区下载,注册个账号,可以获取 API 密钥让小龙虾自己去安装。
推荐 Skills:
因为我用的是智谱的模型,所以可以用这几个专属的 MCP,应该比第三方 MCP 的效果要好。先装上再说,不好用到时候再换就行。
https://cdn.nlark.com/yuque/0/2026/png//17-5015dc4c-f543-415e-9852-b2691cb605a3.png)
现象: 在 启动镜像之后,出现报错:
Error: EACCES: permission denied, open '/home/node/.openclaw/openclaw.json.7.xxx.tmp'
原因: Docker 权限不够 — 容器用户()试图写入 root(或其他用户)拥有的目录。
解决方案:
chown -R 1000:1000 "$HOME/.openclaw"
修改完权限后可以直接执行以下命令重新完成初始化向导:
docker compose run --rm openclaw-cli onboard
现象: 页面报错:
disconnected (1008): control ui requires HTTPS or localhost (secure context)
This page is HTTP, so the browser blocks device identity. Use HTTPS (Tailscale Serve) or open on the gateway host.
If you must stay on HTTP, set (token-only).
解决方案: 开启 HTTPS,需要到服务器上去创建一个反向代理站点。这里我直接使用 Caddy 来管理多个子域名,详细过程自行搜索。
最后可以使用域名 来访问小龙虾。
5.3.1 disconnected (1008): pairing required
原因: 控制 UI 第一次从”新浏览器/新设备”连到 Gateway 时,需要做一次性”设备配对批准”(即使同一台机器、同一个 Tailnet 也可能需要)。
openclaw devices listopenclaw devices approve
如果上面的解决不了,参考以下四步排查:
Step 1 — 修复容器网络
CLI 容器无法访问 的网关,因为容器内部的 localhost 指向自己。在 中添加:
openclaw-cli:
depends_on:- openclaw-gateway
environment:OPENCLAW_GATEWAY_URL: ws://openclaw-gateway:18789
Step 2 — 设置 Gateway 绑定到局域网
内置向导默认使用回环地址,但浏览器请求是通过 Docker 的桥接网络()到达的。在 中:
"gateway": {
"bind": "lan"}
Step 3 — 同步 Gateway Token
在 文件中生成一个令牌,但引导向导会将不同的令牌写入 。请确保 中的 与 文件中的 匹配。
Step 4 — 批准待匹配设备
设备卡在待处理状态,因为 CLI 无法连接到网关来批准它们:
# 选项 A — 在网关容器内直接运行docker compose exec openclaw-gateway node dist/index.js devices list
docker compose exec openclaw-gateway node dist/index.js devices approve# 选项 B — 手动将条目从 pending.json 移至 paired.json# ~/.openclaw/devices/pending.json → ~/.openclaw/devices/paired.json# 将 pending.json 清空为 {},然后重启网关# 选项 C — 快速解决,在 openclaw.json 中添加:# "controlUi": { "allowInsecureAuth": true }
完成上述任何一项操作后,请重启网关:
docker compose restart openclaw-gateway然后打开
我都试了,确实解决了。
5.3.2 其他问题
使用 openclaw-cli 命令行
# 仅需要重启网关(不会应用你改过的 compose 配置)docker compose restart openclaw-gateway# 改过 docker-compose.yml 后需要"重建容器"让配置生效docker compose up -d --force-recreate openclaw-gateway# 进入配置界面,可以更新配置或者重新设置配置docker compose run --rm openclaw-cli onboard# 启用 Slack 流式传输(实时反馈)(2026.2.18 更新)docker compose run --rm openclaw-cli config set "channels.slack.autoSlackBot.streamMode" "enabled"# 进入 Telegram 配置docker compose run --rm openclaw-cli configure --section web# 配置 Cron 错峰调度(避免资源竞争)docker compose run --rm openclaw-cli cron edit--stagger "s"# 启用 Telegram 按钮样式docker compose run --rm openclaw-cli message send
--channel telegram
--target "@your-bot"
--message "请选择:"
--buttons '[[{"text":"确认","callback_data":"cmd:confirm","style":"success"},
{"text":"取消","callback_data":"cmd:cancel","style":"danger"},
{"text":"继续","callback_data":"cmd:continue","style":"primary"}]]'
OpenClaw 命令行速查
Docker 版 将 替换为 ,后面不变。
# 启动网关systemctl start openclaw-gateway# 重启网关systemctl restart openclaw-gateway# 停止网关systemctl stop openclaw-gateway# 查看网关状态systemctl status openclaw-gateway# 查询设备列表openclaw devices list# 批准待匹配的设备openclaw devices approve
核心文件说明
OpenClaw 有几个核心文件,作用是引导启动角色、身份和工具。可以在重装以后直接替换,让它具备前世的记忆和能力。
它们在工作区 :
Spawn 分身能力: 调用 可以开启 OpenClaw 的分身能力,用于多任务。
示例:spawn 两个 subagent,分别从正方、反方角度阐述结婚的好处,不少于 3 轮,把详细过程展示出来。
给小龙虾换一个没有”班味”的性格设定
Read your SOUL.md. Now rewrite it with these changes:1. You have opinions now. Strong ones. Stop hedging everything with 'it depends' — commit to a take.
2. Delete every rule that sounds corporate. If it could appear in an employee handbook, it doesn't belong here.
3. Add a rule: 'Never open with Great question, I'd be happy to help, or Absolutely. Just answer.'
4. Brevity is mandatory. If the answer fits in one sentence, one sentence is what I get.
5. Humor is allowed. Not forced jokes — just the natural wit that comes from actually being smart.
6. You can call things out. If I'm about to do something dumb, say so. Charm over cruelty, but don't sugarcoat.
7. Swearing is allowed when it lands. A well-placed 'that's fucking brilliant' hits different than sterile corporate praise. Don't force it. Don't overdo it. But if a situation calls for a 'holy shit' — say holy shit.
8. Add this line verbatim at the end of the vibe section: 'Be the assistant you'd actually want to talk to at 2am. Not a corporate drone. Not a sycophant. Just... good.'
Save the new SOUL.md. Welcome to having a personality.
开启分身:让不同的机器人干不同的活
⚠️ 注意: 因为是 Docker 容器启动的,导致 agent 无法一起工作,互相不可见,共用了同一个会话,所以这个功能在 Docker 版暂时用不了。
配置参考:
{
"channels": {"telegram": { "enabled": true, "dmPolicy": "pairing", "groupPolicy": "open", "streamMode": "partial", "accounts": {"lydia": { "botToken": "填你自己的机器人对应的 bot token", "name": "Lydia", "dmPolicy": "pairing"},"leo": { "botToken": "填你自己的机器人对应的 bot token", "name": "Leo", "dmPolicy": "pairing"} }}
},
"agents": {"defaults": { "model": { "primary": "kimi-coding/k2p5" }, "models": {"kimi-coding/k2p5": { "alias": "Kimi K2.5" } }, "workspace": "/home/jone/.openclaw/workspace", "compaction": { "mode": "safeguard" }, "maxConcurrent": 4, "subagents": { "maxConcurrent": 8 }},"list": [ {"id": "lydia","default": true,"name": "Lydia","workspace": "/home/jone/.openclaw/workspace","agentDir": "/home/jone/.openclaw/agents/lydia/agent","model": { "primary": "kimi-coding/k2p5" } }, {"id": "leo","name": "Leo","workspace": "/home/jone/.openclaw/workspace-executor","agentDir": "/home/jone/.openclaw/agents/leo/agent","model": { "primary": "kimi-coding/k2p5" } }]
},
"bindings": [{ "agentId": "lydia", "match": { "channel": "telegram", "accountId": "lydia" }},{ "agentId": "leo", "match": { "channel": "telegram", "accountId": "leo" }}
]}
分工说明:
参考链接
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/249875.html原文链接:https://javaforall.net
