version: '3.4' services: aspnetapp.mysql: image: mysql:5.7 container_name: aspnetapp.mysql ports: - "3306:3306" restart: always environment: - MYSQL_ROOT_PASSWORD=123456 - TZ=Asia/Shanghai volumes: - /app/data/mysql:/var/lib/mysql - ./mysql-init:/docker-entrypoint-initdb.d # 挂载初始化 SQL 脚本 - ./mysql-config/my.cnf:/etc/mysql/my.cnf # 挂载自定义配置文件 networks: - aspnetapp-net aspnetapp.web: image: docker.cnb.cool/devopschina/cloud-native-run-dotnet:latest container_name: aspnetapp.web ports: - "8080:80" restart: always depends_on: - aspnetapp.mysql environment: - MYSQL_ADDRESS=aspnetapp.mysql:3306 - MYSQL_USERNAME=root - MYSQL_PASSWORD=123456 - TZ=Asia/Shanghai networks: - aspnetapp-net networks: aspnetapp-net: driver: bridge