在 Hetzner VPS 上通过 Docker 运行持久化 OpenClaw Gateway,约 €3.79/月,性价比最高。
安全模型提示
- 公司共享 agent 适合同一信任边界内的团队
- 严格隔离:专用 VPS/运行时 + 专用账号,不混用个人账号
- 用户互相对立时,按 gateway/主机/OS 用户分离
部署步骤
1. 创建 Hetzner VPS
选择 Ubuntu 或 Debian 系统,记录 IP 地址。
2. 安装 Docker
ssh root@YOUR_VPS_IP
apt-get update && apt-get install -y git curl ca-certificates
curl -fsSL https://get.docker.com | sh
docker --version && docker compose version3. 克隆仓库并创建持久化目录
git clone https://github.com/openclaw/openclaw.git && cd openclaw
mkdir -p /root/.openclaw/workspace
chown -R 1000:1000 /root/.openclaw4. 配置环境变量
# .env 文件
OPENCLAW_IMAGE=openclaw:latest
OPENCLAW_GATEWAY_TOKEN=
OPENCLAW_GATEWAY_BIND=lan
OPENCLAW_GATEWAY_PORT=18789
OPENCLAW_CONFIG_DIR=/root/.openclaw
OPENCLAW_WORKSPACE_DIR=/root/.openclaw/workspace
GOG_KEYRING_PASSWORD=$(openssl rand -hex 32)
XDG_CONFIG_HOME=/home/node/.openclaw5. 配置 docker-compose.yml
关键配置:
restart: unless-stopped- 端口绑定:
"127.0.0.1:${OPENCLAW_GATEWAY_PORT}:18789"(仅本地,通过 SSH 隧道访问) - 挂载
OPENCLAW_CONFIG_DIR和OPENCLAW_WORKSPACE_DIR
6. 构建并启动
参见 install-docker-vm-runtime 的烘焙二进制、构建启动步骤。
7. SSH 隧道访问
确认 /etc/ssh/sshd_config 中 AllowTcpForwarding local,然后:
ssh -N -L 18789:127.0.0.1:18789 root@YOUR_VPS_IP
# 浏览器打开 http://127.0.0.1:18789/Terraform 基础设施即代码
社区维护的 Terraform 方案:
提供模块化配置、cloud-init 自动化、备份恢复脚本。
相关链接
- install-docker-vm-runtime — Docker VM 共享运行时步骤
- install-fly — Fly.io 部署