fix: 使用 host 网络模式避免 Docker bridge 子网与 VPC 内网冲突
Some checks failed
CI/CD Pipeline / Code Quality (push) Successful in 16s
CI/CD Pipeline / Unit Tests (push) Successful in 9s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Failing after 50s

Docker Compose 默认创建的 bridge 网络 (172.23.0.0/16) 与阿里云
RDS 内网 IP 段冲突,导致宿主机到 RDS 的流量被截走,Gitea 无法
连接数据库。改用 network_mode: host 彻底解决。
This commit is contained in:
Wang Zhuoxuan 2026-04-18 02:50:10 +08:00
parent 2141d9a539
commit 23f8c16c54

View File

@ -2,14 +2,14 @@
# 服务器部署配置(单服务器 Phase 1
# 包含生产环境和测试环境(按需启停)
#
# 使用 host 网络模式,避免 Docker bridge 子网与 VPC 内网冲突
#
# 用法:
# 生产环境docker compose up -d
# 含测试: docker compose --profile test up -d
# 停止测试docker compose --profile test stop api-test
# ========================================
version: '3.8'
services:
# ===== 生产环境 =====
api-prod:
@ -19,9 +19,8 @@ services:
image: duoqi-api:prod
container_name: duoqi-api-prod
restart: unless-stopped
network_mode: host
env_file: .env.prod
ports:
- "3000:3000"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
@ -46,9 +45,8 @@ services:
image: duoqi-api:test
container_name: duoqi-api-test
restart: "no"
network_mode: host
env_file: .env.test
ports:
- "3001:3001"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3001/health"]
interval: 30s