version: '3.8' services: happy-cloud-mysql: build: context: /mnt/product/cloud/db env_file: - /mnt/product/cloud/db/env/mysql.env #指定配置文件启动 restart: always container_name: happy-cloud-mysql image: happy-cloud-mysql ports: - 3309:3306 volumes: - /mnt/product/cloud/mysql/data:/var/lib/mysql #挂载 MySQL数据 - /mnt/product/cloud/mysql/conf/my.cnf:/etc/mysql/my.cnf #挂载 mysql配置 hostname: happy-cloud-mysql networks: - custom_net happy-cloud-redis: image: redis:5.0 #宿主机端口修改,避免冲突 ports: - 16379:6379 restart: always #以docker下的/usr/local/etc/redis/redis.conf为配置文件启动 command: redis-server /usr/local/etc/redis/redis.conf --appendonly yes volumes: - /mnt/product/cloud/redis/data:/data #挂载 Redis数据 - /mnt/product/cloud/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf #挂载 Redis配置 container_name: happy-cloud-redis hostname: happy-cloud-redis networks: - custom_net networks: custom_net: external: name: app_net