使用Docker部署OpenClaw漢化中文版的全過程
本文檔詳細介紹如何使用 Docker 部署 OpenClaw 漢化中文版。


一鍵部署腳本(推薦)
自動完成初始化、配置遠程訪問、啟動容器:
# Linux / macOS curl -fsSL https://cdn.jsdelivr.net/gh/1186258278/OpenClawChineseTranslation@main/docker-deploy.sh | bash # Windows PowerShell irm https://cdn.jsdelivr.net/gh/1186258278/OpenClawChineseTranslation@main/docker-deploy.ps1 | iex
本地快速啟動
適用于在本機運行并通過 localhost 訪問:
# 1. 初始化配置(首次運行) docker run --rm -v openclaw-data:/root/.openclaw \ ghcr.io/1186258278/openclaw-zh:latest openclaw setup docker run --rm -v openclaw-data:/root/.openclaw \ ghcr.io/1186258278/openclaw-zh:latest openclaw config set gateway.mode local # 2. 啟動容器 docker run -d \ --name openclaw \ -p 18789:18789 \ -v openclaw-data:/root/.openclaw \ ghcr.io/1186258278/openclaw-zh:latest \ openclaw gateway run
訪問:http://localhost:18789
服務器遠程部署
部署到服務器并從其他設備訪問時,需要額外配置:
# 1. 創(chuàng)建數(shù)據(jù)卷 docker volume create openclaw-data # 2. 初始化配置 docker run --rm -v openclaw-data:/root/.openclaw \ ghcr.io/1186258278/openclaw-zh:latest openclaw setup # 3. 配置遠程訪問參數(shù) docker run --rm -v openclaw-data:/root/.openclaw \ ghcr.io/1186258278/openclaw-zh:latest openclaw config set gateway.mode local docker run --rm -v openclaw-data:/root/.openclaw \ ghcr.io/1186258278/openclaw-zh:latest openclaw config set gateway.bind lan # 4. 設置訪問令牌(推薦) docker run --rm -v openclaw-data:/root/.openclaw \ ghcr.io/1186258278/openclaw-zh:latest openclaw config set gateway.auth.token your-secure-token # 5. 啟動容器 docker run -d \ --name openclaw \ -p 18789:18789 \ -v openclaw-data:/root/.openclaw \ --restart unless-stopped \ ghcr.io/1186258278/openclaw-zh:latest \ openclaw gateway run
訪問:http://服務器IP:18789 → 在 Dashboard 輸入 token 連接
遠程訪問與 Token 認證
通過 HTTP 從非 localhost 訪問時,瀏覽器會阻止設備身份驗證(Web Crypto API 需要 secure context)。
推薦解決方案:設置 Token 認證
# 1. 設置訪問令牌 docker exec openclaw openclaw config set gateway.auth.token YOUR_TOKEN docker restart openclaw # 2. 在瀏覽器訪問遠程地址 http://服務器IP:18789/overview # 3. 在「網(wǎng)關令牌」輸入框填入 YOUR_TOKEN,點擊「連接」
設置 gateway.auth.token 后,即使通過遠程 HTTP 訪問,只要在 Dashboard 輸入正確的 token 就能連接成功。
其他解決方案對比:
| 方案 | 說明 | 適用場景 |
|---|---|---|
| 設置 Token | 設置 gateway.auth.token,Dashboard 輸入 token | 內(nèi)網(wǎng)(最簡單) |
| SSH 端口轉發(fā) | ssh -L 18789:127.0.0.1:18789 user@server | 更安全 |
| Tailscale Serve | 自動 HTTPS 訪問 | 跨網(wǎng)絡訪問 |
| Nginx + HTTPS | 配置 SSL 證書反向代理 | 生產(chǎn)環(huán)境 |
Nginx + HTTPS 反向網(wǎng)絡
如果使用 Nginx 等反向網(wǎng)絡,需要額外配置 gateway.trustedProxies,否則會提示 Proxy headers detected from untrusted address。
1. 配置 OpenClaw 信任代理地址
# Docker 環(huán)境 docker exec openclaw openclaw config set gateway.trustedProxies '["127.0.0.1", "::1"]' docker restart openclaw # npm 安裝環(huán)境 openclaw config set gateway.trustedProxies '["127.0.0.1", "::1"]' openclaw gateway restart
如果 Nginx 和 OpenClaw 在不同服務器,將
127.0.0.1替換為 Nginx 服務器的 IP 地址。
2. Nginx 配置示例
# /etc/nginx/sites-available/openclaw
server {
listen 443 ssl http2;
server_name oc.example.com;
# SSL 證書配置(推薦使用 Let's Encrypt)
ssl_certificate /etc/letsencrypt/live/oc.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/oc.example.com/privkey.pem;
# SSL 安全配置
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers off;
location / {
proxy_pass http://127.0.0.1:18789;
proxy_http_version 1.1;
# WebSocket 支持(必須)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# 轉發(fā)真實客戶端信息
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 超時配置
proxy_read_timeout 86400;
proxy_send_timeout 86400;
}
}
# HTTP 重定向到 HTTPS
server {
listen 80;
server_name oc.example.com;
return 301 https://$server_name$request_uri;
}3. 啟用配置
sudo ln -s /etc/nginx/sites-available/openclaw /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginx
Docker Compose
項目提供了開箱即用的 docker-compose.yml:
# 下載配置文件 curl -fsSL https://cdn.jsdelivr.net/gh/1186258278/OpenClawChineseTranslation@main/docker-compose.yml -o docker-compose.yml # 啟動(首次會自動初始化) docker-compose up -d
或手動創(chuàng)建 docker-compose.yml:
version: '3.8'
services:
openclaw:
image: ghcr.io/1186258278/openclaw-zh:latest
container_name: openclaw
ports:
- "18789:18789"
volumes:
- openclaw-data:/root/.openclaw
environment:
- OPENCLAW_GATEWAY_TOKEN=your-secure-token
restart: unless-stopped
volumes:
openclaw-data:自行構建鏡像
# 1. 克隆漢化項目 git clone https://github.com/1186258278/OpenClawChineseTranslation.git cd OpenClawChineseTranslation # 2. 克隆上游源碼 git clone https://github.com/openclaw/openclaw.git openclaw # 3. 應用漢化 npm run cli -- apply # 4. 構建 Docker 鏡像 cd openclaw docker build -t openclaw-zh:local . # 5. 運行 docker run -d --name openclaw -p 18789:18789 \ -v openclaw-data:/root/.openclaw openclaw-zh:local
常用命令
# 查看日志 docker logs -f openclaw # 停止/重啟容器 docker stop openclaw docker restart openclaw # 進入容器 docker exec -it openclaw sh # 刪除容器 docker stop openclaw && docker rm openclaw # 查看配置 docker exec openclaw openclaw config get gateway # 在容器內(nèi)執(zhí)行 OpenClaw 命令 docker exec openclaw openclaw --help docker exec openclaw openclaw status
空間清理
Docker 鏡像和容器會占用大量磁盤空間(OpenClaw 鏡像約 4GB),建議定期清理:
# 查看 Docker 空間占用 docker system df # 清理已停止的容器 docker container prune -f # 清理未使用的鏡像 docker image prune -f # 清理構建緩存 docker builder prune -f # 一鍵清理所有未使用資源(鏡像、容器、網(wǎng)絡、緩存) docker system prune -a # 連同未使用的數(shù)據(jù)卷一起清理(會刪除數(shù)據(jù),謹慎使用) docker system prune -a --volumes
常見錯誤排查
| 錯誤信息 | 原因 | 解決方案 |
|---|---|---|
Gateway auth is set to token, but no token is configured | 需要 token 認證但未配置 | docker exec openclaw openclaw config set gateway.auth.token YOUR_TOKEN |
Missing config. Run openclaw setup | 未初始化配置 | docker exec openclaw openclaw setup |
control ui requires HTTPS or localhost | HTTP 遠程訪問被瀏覽器安全策略阻止 | 使用 Token 認證或配置 HTTPS 反向代理 |
Proxy headers detected from untrusted address | 反向代理地址未添加到信任列表 | docker exec openclaw openclaw config set gateway.trustedProxies '["127.0.0.1"]' |
pairing required | 新設備需要配對授權 | docker exec openclaw openclaw devices list 然后 devices approve <id> |
gateway token mismatch | Token 認證失敗 | docker exec openclaw openclaw dashboard --print-url 獲取帶 token 的 URL |
| 容器啟動后立即退出 | 缺少必要配置 | docker logs openclaw 查看日志 |
EACCES: permission denied | 數(shù)據(jù)卷權限問題 | 確保使用 named volume 而非 bind mount |
| Docker 拉取鏡像提示 denied | 登錄緩存問題 | docker logout ghcr.io 后重試 |
更新 Docker 鏡像
# 1. 拉取最新鏡像 docker pull ghcr.io/1186258278/openclaw-zh:latest # 2. 停止并刪除舊容器 docker stop openclaw && docker rm openclaw # 3. 用新鏡像啟動(配置自動保留,存儲在數(shù)據(jù)卷中) docker run -d --name openclaw -p 18789:18789 \ -v openclaw-data:/root/.openclaw \ --restart unless-stopped \ ghcr.io/1186258278/openclaw-zh:latest \ openclaw gateway run
總結
恭喜! 至此,你已經(jīng)成功掌握了 OpenClaw 漢化版的完整 Docker 部署方案。
從本地快速啟動到服務器遠程部署,從 Token 認證到 Nginx HTTPS 反向代理,再到日常的空間清理和故障排查——你現(xiàn)在擁有了一個完全自主可控的中文 AI 助手。無論是個人使用還是團隊協(xié)作,OpenClaw 的多平臺支持和自動化同步機制都能滿足你的需求。
以上就是使用Docker部署OpenClaw漢化中文版的全過程的詳細內(nèi)容,更多關于Docker部署OpenClaw漢化中文版的資料請關注腳本之家其它相關文章!
相關文章

OpenClaw Docker部署踩坑全記錄(OpenClaw v2026.3.23)
文章詳細記錄了使用Docker部署OpenClaw的全過程,強調(diào)了使用官方鏡像而非本地build的重要性,并提供了完整的docker-compose配置文件,文章還指導了部署流程和訪問地址,最后解2026-03-26
一文教你OpenClaw Docker 部署并調(diào)用本地Qwen3.5 9B模型
本文詳細介紹了在 Ubuntu 24.04 系統(tǒng)上通過 Docker 部署 Ollama 并運行 Qwen3.5-9B的完整流程,同時對接 OpenClaw 實現(xiàn) Web 交互,文中通過示例代碼介紹的非常詳細,需要的2026-03-12
Windows、macOS、Linux三系統(tǒng)本地部署OpenClaw+避坑指南+Docker一鍵部署,30分鐘搞定
本文給大家分享全網(wǎng)最全的OpenClaw安裝部署教程,覆蓋Windows、macOS、Linux三系統(tǒng)本地部署,并最終提供Docker一鍵部署方案,感興趣的朋友一起看看吧2026-03-10
本文詳細介紹了在MacBook Air M4芯片上使用Docker部署OpenClaw的過程,通過本文的步驟和技巧,讀者可以成功部署并使用OpenClaw作為智能助理,感興趣的朋友跟隨小編一起看看吧2026-03-05





