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 command: --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --explicit_defaults_for_timestamp=true --lower_case_table_names=1 --max_allowed_packet=128M --sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION ports: - 3309:3306 volumes: - /mnt/product/cloud/mysql/data:/var/lib/mysql #挂载 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