一、docker安装
测试环境已安装docker
[root@hecs-276856 ~]# docker --version
Docker version 24.0.7, build afdd53b
二、docker-compose安装
curl -L "https://github.com/docker/compose/releases/download/v2.24.6/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
三、docker-compose.yml文件配置
version: '3.8'
services:
openclaw:
image: ghcr.io/openclaw/openclaw:latest
container_name: openclaw
ports:
- "18789:18789"
- "18791:18791"
volumes:
- /opt/openclaw/docker-compose/data:/home/node/.openclaw //持久话目录配置
environment:
- ANTHROPIC_API_KEY=你的_api_key
- GATEWAY_AUTH_TOKEN=your_secure_token_here
restart: unless-stopped
- 持久话目录权限修改
mkdir -p /opt/openclaw/docker-compose/data
chmod 777 /opt/openclaw/docker-compose/data
四、启动容器
[root@hecs-276856 docker-compose]# ll
总用量 8
drwxrwxrwx 5 777 root 4096 3月 10 10:43 data
-rw-r--r-- 1 root root 377 3月 10 10:32 docker-compose.yml
[root@hecs-276856 docker-compose]# docker-compose up -d
[+] Running 1/2
⠸ Network docker-compose_default Created 0.3s
✔ Container openclaw Started 0.3s
[root@hecs-276856 docker-compose]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
905cf3d9b1d3 ghcr.io/openclaw/openclaw:latest "docker-entrypoint.s…" 4 seconds ago Up 3 seconds (health: starting) 0.0.0.0:18789->18789/tcp, :::18789->18789/tcp, 0.0.0.0:18791->18791/tcp, :::18791->18791/tcp openclaw
[root@hecs-276856 docker-compose]# docker logs openclaw
2026-03-10T02:43:44.451+00:00 [gateway] auth token was missing. Generated a new token and saved it to config (gateway.auth.token).
2026-03-10T02:43:45.281+00:00 [canvas] host mounted at http://127.0.0.1:18789/__openclaw__/canvas/ (root /home/node/.openclaw/canvas)
2026-03-10T02:43:45.373+00:00 [heartbeat] started
2026-03-10T02:43:45.405+00:00 [health-monitor] started (interval: 300s, startup-grace: 60s, channel-connect-grace: 120s)
2026-03-10T02:43:45.410+00:00 [gateway] agent model: anthropic/claude-opus-4-6
2026-03-10T02:43:45.412+00:00 [gateway] listening on ws://127.0.0.1:18789 (PID 14)
2026-03-10T02:43:45.425+00:00 [gateway] log file: /tmp/openclaw/openclaw-2026-03-10.log
2026-03-10T02:43:45.504+00:00 [browser/server] Browser control listening on http://127.0.0.1:18791/ (auth=token)
五.修改监听地址(方便浏览器访问,本地部署可忽略)
1.删除旧的容器
[root@hecs-276856 docker-compose]# docker-compose down
[+] Running 2/2
✔ Container openclaw Removed 0.2s
✔ Network docker-compose_default Removed
2.修改openclaw配置
[root@hecs-276856 docker-compose]# cat data/openclaw.json
[root@hecs-276856 data]# cat openclaw.json
{
"meta": {
"lastTouchedVersion": "2026.3.8",
"lastTouchedAt": "2026-03-10T02:28:58.507Z"
},
"agents": {
"defaults": {
"contextPruning": {
"mode": "cache-ttl",
"ttl": "1h"
},
"compaction": {
"mode": "safeguard"
},
"heartbeat": {
"every": "30m"
}
}
},
"commands": {
"native": "auto",
"nativeSkills": "auto",
"restart": true,
"ownerDisplay": "raw"
},
"gateway": {
"bind": "lan", //监听0.0.0.0
"controlUi": {
"allowedOrigins": [ //**CORS白名单访问地址,不推荐使用*(通配符)
"http://127.0.0.1:18789",
"http://localhost:18789",
"http://个人访问ip:18789"
]
},
"auth": {
"mode": "token",
"token": "7a03bbaa4a2727940d3610421643fe64963384f4a880011e"
}
}
}
3.启动容器
[root@hecs-276856 docker-compose]# docker-compose up -d
[+] Running 1/2
⠸ Network docker-compose_default Created 0.3s
✔ Container openclaw Started 0.3s
[root@hecs-276856 docker-compose]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0cb3bcd6ed9e ghcr.io/openclaw/openclaw:latest "docker-entrypoint.s…" 2 seconds ago Up 2 seconds (health: starting) 0.0.0.0:18789->18789/tcp, :::18789->18789/tcp, 0.0.0.0:18791->18791/tcp, :::18791->18791/tcp openclaw
[root@hecs-276856 docker-compose]# docker logs openclaw
2026-03-10T02:47:18.139+00:00 [canvas] host mounted at http://0.0.0.0:18789/__openclaw__/canvas/ (root /home/node/.openclaw/canvas)
2026-03-10T02:47:18.142+00:00 [gateway] ⚠️ Gateway is binding to a non-loopback address. Ensure authentication is configured before exposing to public networks.
2026-03-10T02:47:18.201+00:00 [heartbeat] started
2026-03-10T02:47:18.204+00:00 [health-monitor] started (interval: 300s, startup-grace: 60s, channel-connect-grace: 120s)
2026-03-10T02:47:18.207+00:00 [gateway] agent model: anthropic/claude-opus-4-6
2026-03-10T02:47:18.209+00:00 [gateway] listening on ws://0.0.0.0:18789 (PID 15)
2026-03-10T02:47:18.211+00:00 [gateway] log file: /tmp/openclaw/openclaw-2026-03-10.log
2026-03-10T02:47:18.243+00:00 [browser/server] Browser control listening on http://127.0.0.1:18791/ (auth=token)