docker-compose.yml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. version: '3.8'
  2. services:
  3. happy-cloud-mysql:
  4. build:
  5. context: /mnt/product/cloud/db
  6. env_file:
  7. - /mnt/product/cloud/db/env/mysql.env #指定配置文件启动
  8. restart: always
  9. container_name: happy-cloud-mysql
  10. image: happy-cloud-mysql
  11. command:
  12. --character-set-server=utf8mb4
  13. --collation-server=utf8mb4_general_ci
  14. --explicit_defaults_for_timestamp=true
  15. --lower_case_table_names=1
  16. --max_allowed_packet=128M
  17. --sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
  18. ports:
  19. - 3309:3306
  20. volumes:
  21. - /mnt/product/cloud/mysql/data:/var/lib/mysql #挂载 MySQL数据
  22. hostname: happy-cloud-mysql
  23. networks:
  24. - custom_net
  25. happy-cloud-redis:
  26. image: redis:5.0
  27. #宿主机端口修改,避免冲突
  28. ports:
  29. - 16379:6379
  30. restart: always
  31. #以docker下的/usr/local/etc/redis/redis.conf为配置文件启动
  32. command: redis-server /usr/local/etc/redis/redis.conf --appendonly yes
  33. volumes:
  34. - /mnt/product/cloud/redis/data:/data #挂载 Redis数据
  35. - /mnt/product/cloud/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf #挂载 Redis配置
  36. container_name: happy-cloud-redis
  37. hostname: happy-cloud-redis
  38. networks:
  39. - custom_net
  40. networks:
  41. custom_net:
  42. external:
  43. name: app_net