OpenClaw Docker x Feishu Bot
部署 OpenClaw 并对接飞书机器人的 Docker 实践笔记。
Infrastructure
UID 1000 Problem: OpenClaw 镜像默认使用 node (UID 1000)。宿主机即使是 ubuntu (UID 1000) 也要确保挂载目录权限对齐。
# 宿主机mkdir -p ~/.openclaw/workspacesudo chown -R 1000:1000 ~/.openclawNetwork & Build
国内环境构建镜像必须走代理。利用 Host 网络模式透传本地代理。
# 1. SSH Remote Forward (Local -> Remote)# ~/.ssh/configRemoteForward 7890 127.0.0.1:7890
# 2. Docker Build with Proxydocker build \ --network=host \ --build-arg http_proxy=http://127.0.0.1:7890 \ --build-arg https_proxy=http://127.0.0.1:7890 \ -t openclaw:local .Feishu Configuration
推荐 WebSocket 长连接模式,无需公网 IP 和备案域名。
-
飞书开发者后台: 启用机器人能力。 订阅事件:
im.message.receive_v1。 不需要配置 "Request URL"。 -
OpenClaw Config (
openclaw.json):gateway.bind:"lan"(允许局域网/外网访问)。channels.feishu: 填入 AppID & Secret。
{ "auth": { "profiles": { "zai:default": { "provider": "zai", "mode": "api_key", "apiKey": "sk-..." } } }, "gateway": { "port": 18789, "bind": "lan" }, "channels": { "feishu": { "enabled": true, "appId": "cli_...", "appSecret": "..." } }, "plugins": { "entries": { "feishu": { "enabled": true } } }}Pitfalls
zod missing: 容器内 npm 安装依赖可能不完整,确保 build 阶段网络通畅。
Gateway Bind: 默认 localhost 只能用于本机调试,服务器部署必须改为 lan 或 0.0.0.0。