docker-compose2.yml 969 B

12345678910111213141516171819202122232425262728293031323334
  1. services:
  2. mysql80-2:
  3. image: registry.cn-chengdu.aliyuncs.com/reghao/mysql:8.0.36
  4. container_name: mysql80-2
  5. hostname: node212
  6. restart: always
  7. network_mode: host
  8. environment:
  9. MYSQL_ROOT_PASSWORD: "Root_123456"
  10. volumes:
  11. - /etc/localtime:/etc/localtime:ro
  12. - /opt/docker/mysql/conf/my.cnf:/etc/mysql/conf.d/my.cnf
  13. - /opt/docker/mysql/data:/var/lib/mysql
  14. - /opt/docker/mysql/log:/var/log/mysql
  15. # 🚨 容器日志限制
  16. logging:
  17. driver: "json-file"
  18. options:
  19. max-size: "100m"
  20. max-file: "3"
  21. # 🚨 资源限制(与节点 1 保持严格对称)
  22. deploy:
  23. resources:
  24. limits:
  25. cpus: '2.0'
  26. memory: 4G
  27. reservations:
  28. cpus: '1.0'
  29. memory: 2G
  30. healthcheck:
  31. test: [ "CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-u", "root", "-p$${MYSQL_ROOT_PASSWORD}" ]
  32. interval: 5s
  33. timeout: 5s
  34. retries: 10