GoTest/config/dev.yaml
Table 62482b371c fix: 修复 Docker 容器连接宿主机 MySQL/Redis 问题并更新文档
主要改动:

1. Docker Compose 配置优化(dev/stage/prod):
   - 移除 mysql 和 redis 服务定义,改为使用宿主机服务
   - 更新 extra_hosts 使用宿主机实际 IP (192.168.1.11) 替代 host-gateway
   - 解决 rootless Docker 网络连接问题

2. Config 配置文件更新(dev/stage/prod):
   - 更新 database.host 和 redis.host 为 host.docker.internal
   - 支持容器通过 host.docker.internal 访问宿主机服务

3. README.md 文档完善:
   - 添加 Docker 容器连接宿主机 MySQL/Redis 的完整排查指南
   - 添加 MySQL 容器无法正常停止的解决方案
   - 更新 Docker Compose 环境说明
   - 添加常见错误信息和排查步骤

问题修复:
- 修复容器无法连接宿主机 MySQL(bind-address 和用户权限问题)
- 修复容器无法连接宿主机 Redis(bind 和 protected-mode 问题)
- 修复 rootless Docker 的 host-gateway 问题(使用宿主机实际 IP)

相关配置要求:
- MySQL: bind-address = 0.0.0.0, root@'%' 用户权限
- Redis: bind = 0.0.0.0, protected-mode = no
2025-11-29 06:55:50 +08:00

42 lines
810 B
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

server:
port: 1234
mode: debug
database:
host: host.docker.internal # Docker环境使用host.docker.internal访问宿主机本地环境使用localhost
port: 3306
username: root
password: sasasasa
dbname: yinli
charset: utf8mb4
parseTime: true
loc: Local
maxIdleConns: 10
maxOpenConns: 100
redis:
host: host.docker.internal # Docker环境使用host.docker.internal访问宿主机本地环境使用localhost
port: 6379
password: ""
db: 0
poolSize: 10
jwt:
secret: dev-jwt-secret-key-change-in-production
expireHours: 24
rateLimit:
enabled: true
requests: 100
window: 60 # seconds
cors:
allowOrigins: ["*"]
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
allowHeaders: ["*"]
log:
level: debug
format: json
output: stdout