February 22, 2026 WordPress教程

OpenClaw Docker 安装指南 🐳

OpenClaw Docker 安装指南 🐳

Docker 是 OpenClaw 的 可选安装方式,适合想要容器化部署或在没有本地安装的主机上运行的用户。

🤔 什么时候使用 Docker?

✅ 适合使用 Docker:

  • 需要隔离的、可丢弃的 Gateway 网关环境
  • 在 VPS 或远程主机上运行 OpenClaw
  • 想要容器化的部署方式

❌ 不建议使用 Docker:

  • 在自己的机器上开发,想要最快的开发循环
  • 使用正常的本地安装流程即可

📋 安装要求

  • Docker Desktop(或 Docker Engine)+ Docker Compose v2
  • 足够的磁盘空间用于镜像 + 日志

🚀 快速开始(推荐)

从仓库根目录运行:

./docker-setup.sh

这个脚本会自动完成:

  • ✅ 构建 Gateway 网关镜像
  • ✅ 运行新手引导向导
  • ✅ 通过 Docker Compose 启动 Gateway 网关
  • ✅ 生成 Gateway 网关令牌并写入 `.env`

完成后的步骤:

  1. 打开浏览器访问 http://127.0.0.1:18789/
  2. 将令牌粘贴到控制 UI(设置 → token)
  3. 需要获取新令牌时运行:docker compose run --rm openclaw-cli dashboard --no-open

⚙️ 高级配置选项

1. 挂载额外目录

export OPENCLAW_EXTRA_MOUNTS="$HOME/.codex:/home/node/.codex:ro,$HOME/github:/home/node/github:rw"
./docker-setup.sh

2. 持久化 `/home/node`

export OPENCLAW_HOME_VOLUME="openclaw_home"
./docker-setup.sh

3. 安装额外系统包

export OPENCLAW_DOCKER_APT_PACKAGES="ffmpeg build-essential"
./docker-setup.sh

🔐 控制 UI 令牌配置

如果遇到 “unauthorized” 或 “pairing required” 错误:

docker compose run --rm openclaw-cli dashboard --no-open
docker compose run --rm openclaw-cli devices list
docker compose run --rm openclaw-cli devices approve <requestId>

🧪 健康检查

docker compose exec openclaw-gateway node dist/index.js health --token "$OPENCLAW_GATEWAY_TOKEN"

🏗️ 智能体沙箱(可选功能)

当启用 `agents.defaults.sandbox` 时,非主会话会在 Docker 容器内运行工具:

  • Scope 模式:`agent`(每个智能体一个容器)或 `session`(每会话隔离)
  • 工作区访问:`none` | `ro`(只读)| `rw`(读写)
  • 自动清理:空闲 > 24h 或 年龄 > 7d

📚 更多资源

本文基于 OpenClaw 官方文档编写。


发布时间:2026-02-22

Leave a Reply

Your email address will not be published. Required fields are marked *