Please enable Javascript to view the contents

容器化部署 Hermes Agent

 ·  ☕ 2 分钟

1. 启动容器

  • 设置镜像
1
export IMAGE=nousresearch/hermes-agent:v2026.4.16
  • 设置目录权限
1
2
mkdir -p hermes-agent-home
chmod -R 777 hermes-agent-home
  • 设置环境变量
1
2
3
cat <<EOF > hermes-agent-home/.env
GATEWAY_ALLOW_ALL_USERS=true
EOF
  • 创建网络
1
nerdctl network create hermes-net
  • 启动 hermes-agent
1
2
3
4
5
6
7
8
nerdctl run -d \
  --name hermes-agent \
  --restart always \
  --network hermes-net \
  -v $(pwd)/hermes-agent-home:/opt/data \
  -v $(pwd)/openclaw-home/.openclaw:/root/.openclaw \
  -p 8642:8642 \
  $IMAGE gateway run
  • 启动 hermes-agent dashboard
1
2
3
4
5
6
7
8
nerdctl run -d \
  --name hermes-dashboard \
  --restart always \
  --network hermes-net \
  -p 9119:9119 \
  -v $(pwd)/hermes-agent-home:/opt/data \
  -e GATEWAY_HEALTH_URL=http://hermes-net:8642 \
  $IMAGE dashboard --host 0.0.0.0 --insecure
  • 删除容器
1
nerdctl rm hermes-agent hermes-dashboard --force

2. 基本使用

  • 进入容器
1
nerdctl exec -it hermes-agent bash
  • 设置模型
1
/opt/hermes/.venv/bin/hermes model

这里我选择的是自定义模型 (○) 26. Custom endpoint (enter URL manually)

  • 聊天
1
/opt/hermes/.venv/bin/hermes chat -q "hi"
  • 导入 OpenClaw
1
/opt/hermes/.venv/bin/hermes claw migrate
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
┌─────────────────────────────────────────────────────────┐
│          ⚕ Hermes — OpenClaw Migration                 │
└─────────────────────────────────────────────────────────┘


◆ Migration Settings
  Source:      /root/.openclaw
  Target:      /opt/data
  Preset:      full
  Overwrite:   no (skip conflicts)
  Secrets:     yes (allowlisted only)
  • 诊断
1
/opt/hermes/.venv/bin/hermes doctor
  • 进入 TUI
1
/opt/hermes/.venv/bin/hermes
  • 添加电报
1
2
echo "TELEGRAM_BOT_TOKEN=xxx
TELEGRAM_ALLOWED_USERS=xxx" >> /opt/data/.env

添加用户白名单限制。

1
/opt/hermes/.venv/bin/hermes gateway restart

3. 远程调用集成

  • 集成逻辑

在部署机器上部署 server 提供 API ,参考 https://github.com/shaowenchen/demo/tree/master/hermes-agent-call 。server 接受到请求之后,在主机上执行如下命令:

1
nerdctl exec -it hermes-agent /opt/hermes/.venv/bin/hermes chat --yolo -c -q "巡检一下集群"

这里的 -c 保持一个回话,便于 Hermes Agent 的自我进化。

  • 使用 pm2 托管服务
1
pm2 start "python3  hermes-agent-call.py" --name hermes-agent
  • 调用方式
1
curl -X POST http://127.0.0.1:3011/call -H "Content-Type: application/json" -d '{"message":"hi"}'
1
{"ok": true, "sessionid": "", "message": "hi", "command": "nerdctl exec hermes-agent /opt/hermes/.venv/bin/hermes chat --yolo -c -q \"hi\"", "exitCode": 0, "stdout": "Hey chenshaowen! 👋\nWhat can I help you with today?", "stderr": ""}

4. 查看面板

Hermes Agent 的面板,目前不能直接对话,主要用来配置和检查状态。


微信公众号
作者
微信公众号