docker-compose.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. version: "3.3"
  2. services:
  3. # mysql 容器
  4. mysql:
  5. container_name: crmeb_mysql #指定容器名
  6. image: mysql:5.7 #一般电脑可以用这个镜像
  7. platform: linux/x86_64
  8. ports:
  9. - 3336:3306
  10. # 环境变量
  11. environment:
  12. TZ: Asia/Shanghai
  13. MYSQL_ROOT_PASSWORD: "123456"
  14. MYSQL_USER: "crmeb"
  15. MYSQL_PASS: "123456"
  16. MYSQL_DATABASE: "crmeb"
  17. privileged: true
  18. command: --character-set-server=utf8mb4
  19. --collation-server=utf8mb4_general_ci
  20. --explicit_defaults_for_timestamp=true
  21. --lower_case_table_names=1
  22. --max_allowed_packet=128M
  23. --default-authentication-plugin=mysql_native_password
  24. --sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
  25. working_dir: /var/lib/mysql
  26. volumes:
  27. - ./mysql/my.cnf:/etc/mysql/my.cnf
  28. - ./mysql/data:/var/lib/mysql #挂载数据目录到本地
  29. - ./mysql/log:/var/log/mysql
  30. networks:
  31. app_net:
  32. # 固定子网ip,网段必须在子网络192.168.*.*
  33. ipv4_address: 192.168.10.11
  34. # redis 容器
  35. redis:
  36. container_name: crmeb_redis
  37. image: "redis:alpine"
  38. # image: daocloud.io/library/redis:6.0.5-alpine
  39. # image: redis:5.0
  40. ports:
  41. - "6379:6379"
  42. command: redis-server /usr/local/etc/redis/redis.conf
  43. volumes:
  44. # - ./redis/data:/data #挂载数据目录到本地
  45. - ./redis/redis.conf:/usr/local/etc/redis/redis.conf
  46. networks:
  47. app_net:
  48. ipv4_address: 192.168.10.10
  49. # php 容器
  50. phpfpm:
  51. container_name: crmeb_php #指定容器名
  52. # image: phpfpm-image #指定镜像名
  53. image: crmeb_php #指定镜像名
  54. build:
  55. context: ./php #dockerfile文件路径
  56. dockerfile: Dockerfile #制定dockerfile文件名称
  57. restart: always
  58. environment:
  59. TZ: Asia/Shanghai
  60. ports:
  61. - 9000:9000
  62. - 40001:40001
  63. - 40002:40002
  64. - 40003:40003
  65. tmpfs: /var/temp #上传临时文件夹
  66. working_dir: /var/www
  67. volumes:
  68. - ../../crmeb:/var/www #程序运行目录
  69. - ../../crmeb/runtime:/var/www/temp #程序缓存目录
  70. - ./php/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini
  71. networks:
  72. app_net:
  73. ipv4_address: 192.168.10.90
  74. # nginx 容器
  75. nginx:
  76. container_name: crmeb_nginx
  77. image: "nginx:alpine"
  78. # image: daocloud.io/library/nginx:1.19.1-alpine
  79. restart: always
  80. ports:
  81. - 8011:80
  82. # - 443:443
  83. # 依赖关系 先跑php
  84. depends_on:
  85. - phpfpm
  86. environment:
  87. TZ: Asia/Shanghai
  88. working_dir: /var/www
  89. volumes_from:
  90. - phpfpm #继承phpfpm挂载目录
  91. volumes:
  92. - ./nginx/vhost.conf:/etc/nginx/conf.d/default.conf
  93. - ./nginx/log:/etc/nginx/log
  94. networks:
  95. app_net:
  96. ipv4_address: 192.168.10.80
  97. networks: #网络配置
  98. app_net: #网络名称
  99. driver: bridge
  100. ipam: #网络配置
  101. driver: default
  102. config:
  103. - subnet: 192.168.10.0/24 #IP区间