# ==================== Nacos 集群 (3节点高可用) ====================
  nacos:
    image: registry.xxxx.com/nacos:20260709_fix2
    hostname: nacos
    environment:
      TZ: Asia/Shanghai
      NACOS_STANDALONE: "false"
      NACOS_SERVERS: "172.31.0.70:8848,172.31.0.71:8848,172.31.0.72:8848"
      JAVA_OPTS: >-
        -Xms256m -Xmx512m -Dserver.port=8848
        -Ddb.url.0=jdbc:mysql://172.31.0.70:3306/config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
      SPRING_DATASOURCE_PLATFORM: mysql
    ports:
      - mode: host
        target: 8848
        published: 8848
        protocol: tcp
      - mode: host
        target: 9848
        published: 9848
        protocol: tcp
      - mode: host
        target: 7848
        published: 7848
        protocol: tcp
      - mode: host
        target: 9849
        published: 9849
        protocol: tcp
    volumes:
      - /data/bigdata/logs/nacos:/jiuyun/nacos/logs
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8848/nacos/v1/console/health/readiness"]
      interval: 15s
      timeout: 5s
      retries: 5
      start_period: 120s
    deploy:
      replicas: 3
      endpoint_mode: dnsrr
      placement:
        constraints:
          - node.labels.nacos==true
      restart_policy:
        condition: any
    networks:
      - app-net

更多推荐