# 配置各个容器服务 services: microService: image: zzyy_docker:1.6 container_name: ms01 # 容器名称,如果不指定,会生成一个服务名加上前缀的容器名 ports: - "6001:6001" volumes: - /app/microService:/data networks: - springboot_network depends_on: # 配置该容器服务所依赖的容器服务 - redis - mysql redis: image: redis:6.0.8 ports: - "6379:6379" volumes: - /app/redis/redis.conf:/etc/redis/redis.conf - /app/redis/data:data networks: - springboot_network command: redis-server /etc/redis/redis.conf mysql: image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: '123456' MYSQL_ALLOW_EMPTY_PASSWORD: 'no' MYSQL_DATABASE: 'db_springboot' MYSQL_USER: 'springboot' MYSQL_PASSWORD: 'springboot' ports: - "3306:3306" volumes: - /app/mysql/db:/var/lib/mysql - /app/mysql/conf/my.cnf:/etc/my.cnf - /app/mysql/init:/docker-entrypoint-initdb.d networks: - springboot_network command: --default-authentication-plugin=mysql_native_password # 解决外部无法访问 networks: # 创建 springboot_network 网桥网络 springboot_network:
标签:compose,springboot,app,MYSQL,redis,mysql,docker,yml,network From: https://www.cnblogs.com/r1-12king/p/18287911