主要改动: 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
16 lines
287 B
YAML
16 lines
287 B
YAML
services:
|
|
yinli-api:
|
|
build:
|
|
context: ..
|
|
dockerfile: Dockerfile
|
|
ports:
|
|
- "1234:1234"
|
|
environment:
|
|
- APP_ENV=stage
|
|
volumes:
|
|
- ../config:/app/config:ro
|
|
extra_hosts:
|
|
- "host.docker.internal:192.168.1.11"
|
|
restart: unless-stopped
|
|
|