首页 > 其他资讯 > docker升级openclaw版本

docker升级openclaw版本

时间:26-04-07

容器内升级OpenClaw

当你需要升级Docker容器内的OpenClaw时,一个关键步骤是以root用户身份进入容器。默认情况下,使用docker run命令会以node用户启动,这可能会在后续的权限操作中带来麻烦。所以,请务必带上-u root参数。

免费影视、动漫、音乐、游戏、小说资源长期稳定更新! 👉 点此立即查看 👈

进入容器后,可以执行以下一系列命令来完成升级:

# 1. 强制安装最新版并覆盖旧链接
npm install -g openclaw@latest --force --registry=https://registry.npmmirror.com
# 2. 建立目录软链接(将 npm 全局路径映射到 app 工作目录)
rm -rf /app/dist /app/node_modules
ln -sf /usr/local/lib/node_modules/openclaw/dist /app/dist
ln -sf /usr/local/lib/node_modules/openclaw/node_modules /app/node_modules
# 3. 清理旧版模型缓存(激活 128k 规格的关键)
rm -f /root/.openclaw/models.json
# 4. 权限归属与启动
chown -R node:node /root/.openclaw
exec node /app/dist/index.js gateway

这里有个细节需要注意:通过npm install升级OpenClaw Gateway后,Web UI的前端文件并不会自动指向新目录/usr/local/lib/node_modules/openclaw/dist。这会导致即使openclaw --version显示版本已更新,Web UI界面呈现的依然是旧版本。解决方法很简单,就是手动建立软链接,将新版本的目录覆盖到旧路径上。

遇到的问题

升级过程中,你可能会遇到下面几个典型问题:

报错 说明 解决
Missing config. Run openclaw setup or set gateway.mode=local (or pass --allow-unconfigured). 出现类似配置文件已配置但读不到的情况,需要注意检查当前用户,启动命令会在当前用户目录下.openclaw找json 切换到对应用户
npm error code EEXIST、npm error path /usr/local/bin/openclaw、npm error EEXIST: file already exists openclaw二进制文件已存在,无直接覆盖 npm install -g openclaw@latest 加上 --force
如果你只想本地访问 - bind 的值lan改成 loopback

重建OpenClaw

如果不慎误操作导致OpenClaw无法启动,也不必慌张。你可以使用下面的启动命令,直接重建一个基于最新版本OpenClaw的容器。这个命令本质上是模拟了官方docker-setup.sh脚本拉取openclaw:local镜像并初始化的过程。

docker run -d \
--name openclaw-prod \
--restart unless-stopped \
-u root \
--memory=8g \
-p 18789:18789 \
-p 18790:18790 \
-v /root/.openclaw:/root/.openclaw \
-v /root/.openclaw/workspace:/root/.openclaw/workspace \
-e NODE_ENV=production \
-e NODE_OPTIONS="--max-old-space-size=4096" \
--entrypoint "/bin/sh" \
openclaw:local \
-c "npm install -g openclaw@latest --force --registry=https://registry.npmmirror.com && \
rm -rf /app/dist /app/node_modules && \
ln -sf /usr/local/lib/node_modules/openclaw/dist /app/dist && \
ln -sf /usr/local/lib/node_modules/openclaw/node_modules /app/node_modules && \
exec node /app/dist/index.js gateway"

重建或配置时,openclaw.json配置文件中的gateway部分是核心,其结构通常如下:

"gateway": {
  "port": 18789,
  "mode": "local",
  "bind": "lan",
  "controlUi": {
    "enabled": true,
    "allowedOrigins": [
      "http://物理机ip:18789",
      "http://127.0.0.1:18789",
      "http://localhost:18789"
    ],
    "dangerouslyAllowHostHeaderOriginFallback": true,
    "allowInsecureAuth": true,
    "dangerouslyDisableDeviceAuth": true
  },
  "auth": {
    "mode": "token",
    "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #gateway授权token
  },
  "trustedProxies": ["192.168.65.0/24", "172.18.0.0/16"],
  "tailscale": {
    "mode": "off",
    "resetOnExit": false
  },
  "nodes": {
    "denyCommands": [
      "camera.snap",
      "camera.clip",
      "screen.record",
      "contacts.add",
      "calendar.add",
      "reminders.add",
      "sms.send"
    ]
  }
},

此外,openclaw.json中的tools部分关系到工具调用与安全策略,典型的配置示例如下:

"tools": {
  "profile": "coding",
  "exec": {
    "host": "gateway",
    "security": "full",
    "ask": "on-miss"
  }
},

这就是docker升级openclaw版本的全部内容了,希望以上内容对小伙伴们有所帮助,更多详情可以关注我们的菜鸟游戏和软件相关专区,更多攻略和教程等你发现!

热搜     |     排行     |     热点     |     话题     |     标签

手机版 | 电脑版 | 客户端

湘ICP备2022003375号-1

本站所有软件,来自于互联网或网友上传,版权属原著所有,如有需要请购买正版。如有侵权,敬请来信联系我们,cn486com@outlook.com 我们立刻删除。