# ============================================================================= # ClawPanel Docker Compose 配置 # ============================================================================= # 使用方法: # 1. 快速启动: docker compose up -d # 2. 查看日志: docker compose logs -f # 3. 停止服务: docker compose down # 4. 重新构建: docker compose up -d --build # ============================================================================= services: # --------------------------------------------------------------------------- # ClawPanel Web 服务 # --------------------------------------------------------------------------- clawpanel: build: context: . dockerfile: Dockerfile # 使用 BuildKit 构建缓存 cache_from: - clawpanel:build-cache args: - NPM_REGISTRY=https://registry.npmmirror.com container_name: clawpanel hostname: clawpanel # ------------------------------------------------------------------------- # 网络配置 - 关键:使用 host 网络模式解决容器内外互通问题 # ------------------------------------------------------------------------- # host 模式:容器共享宿主机网络命名空间 # 优点: # 1. 容器可以直接访问宿主机上的服务(如 Gateway) # 2. 避免端口映射的复杂性 # 3. 性能更好(无额外网络层) # 注意:使用 host 模式后,ports 配置无效 # ------------------------------------------------------------------------- network_mode: host # ------------------------------------------------------------------------- # 端口映射(仅在 network_mode 为 default 时生效) # 如果你想用 bridge 模式而不是 host 模式,注释上面一行,取消下面注释 # ------------------------------------------------------------------------- # ports: # - "1420:1420" # ClawPanel Web 界面 # ------------------------------------------------------------------------- # 卷挂载 - 数据持久化 # ------------------------------------------------------------------------- volumes: # OpenClaw 配置目录 - 关键! # 包含 openclaw.json, mcp.json, agents/, devices/ 等 - ~/.openclaw:/root/.openclaw # ClawPanel 数据目录(可选,用于存储临时文件) - ./data:/app/data # ------------------------------------------------------------------------- # 环境变量 # ------------------------------------------------------------------------- environment: - NODE_ENV=production # OpenClaw Gateway 地址(如果 Gateway 不在本地,修改为实际地址) # 注意:host 模式下直接使用 localhost 或 127.0.0.1 - OPENCLAW_URL=http://127.0.0.1:18789 # 如果需要代理(取消注释并修改为实际代理地址) # - HTTP_PROXY=http://host.docker.internal:7890 # - HTTPS_PROXY=http://host.docker.internal:7890 # 时区设置 - TZ=Asia/Shanghai # 确保 HOME 环境变量正确 - HOME=/root # ------------------------------------------------------------------------- # 重启策略 # ------------------------------------------------------------------------- restart: unless-stopped # ------------------------------------------------------------------------- # 健康检查 # ------------------------------------------------------------------------- healthcheck: test: ["CMD", "curl", "-f", "http://localhost:1420/"] interval: 30s timeout: 5s retries: 3 start_period: 15s # ------------------------------------------------------------------------- # 安全配置 # ------------------------------------------------------------------------- # 使用读安全选项减少攻击面 security_opt: - no-new-privileges:true # ------------------------------------------------------------------------- # 资源限制(可选,取消注释以限制资源使用) # ------------------------------------------------------------------------- # deploy: # resources: # limits: # cpus: '1.0' # memory: 1G # reservations: # cpus: '0.5' # memory: 512M # ------------------------------------------------------------------------- # 日志配置 # ------------------------------------------------------------------------- logging: driver: "json-file" options: max-size: "10m" max-file: "3" # ------------------------------------------------------------------------- # 依赖(可选,如果 Gateway 在另一个容器中) # ------------------------------------------------------------------------- # depends_on: # gateway: # condition: service_healthy # --------------------------------------------------------------------------- # OpenClaw Gateway 服务(可选,取消注释以启用) # --------------------------------------------------------------------------- # gateway: # image: node:22-alpine # container_name: openclaw-gateway # hostname: openclaw-gateway # network_mode: host # volumes: # - ~/.openclaw:/root/.openclaw # environment: # - TZ=Asia/Shanghai # restart: unless-stopped # command: > # sh -c "npm install -g @qingchencloud/openclaw-zh --registry https://registry.npmmirror.com && # openclaw init 2>/dev/null || true && # openclaw gateway start --foreground" # healthcheck: # test: ["CMD", "curl", "-f", "http://localhost:18789/health"] # interval: 30s # timeout: 5s # retries: 3 # logging: # driver: "json-file" # options: # max-size: "10m" # max-file: "3" # ============================================================================= # 网络配置(使用 host 模式时不需要) # ============================================================================= # networks: # default: # name: clawpanel-network # driver: bridge # ============================================================================= # 卷配置 # ============================================================================= # volumes: # openclaw-config: # name: clawpanel-openclaw-config