docker-compse模板

这是一个使用docker-compose.yml配置多个服务的示例,包括Nacos配置管理服务、多个应用服务如upms、auth、tx等,每个服务都有自己的Dockerfile,配置了环境变量、端口映射、日志存储路径以及健康检查机制,确保服务的稳定运行。
摘要由CSDN通过智能技术生成

1.全量服务docker-compose.yml 的模板demo

version : '3.1'
services:
  nacos:
    image: nacos/nacos-server:1.4.1
    container_name: nacos
    environment:
      # 支持主机名可以使用hostname,否则使用ip,默认ip
      - PREFER_HOST_MODE=ip
      # 单机模式
      - MODE=standalone
      # 数据源平台 支持mysql或不保存empty
      - SPRING_DATASOURCE_PLATFORM=mysql
      # mysql配置,!!!attention必须是mysql所在主机IP
      - MYSQL_SERVICE_HOST=192.168.19.145
      - MYSQL_SERVICE_PORT=13306
      - MYSQL_SERVICE_USER=root
      - MYSQL_SERVICE_PASSWORD=root
      - MYSQL_SERVICE_DB_NAME=guangrui_config
    volumes:
      - ./nacos/logs:/home/nacos/logs
    ports:
      - 8848:8848 
    restart: always
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:8848/nacos/v1/console/health/readiness"]
      interval: 10s
      timeout: 3s
      retries: 30

    network_mode: host
  upms:
    container_name: upms
    build:
      context: ./km-upms/
      dockerfile: Dockerfile
    ports:
      - "4000:4000"
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    volumes:
      - ./logs/:/app/logs
    network_mode: host
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:4000/actuator/health/"]
      interval: 10s
      timeout: 3s
      retries: 30
    restart: always

  auth:
    container_name: auth
    build:
      context: ./km-auth/
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    volumes:
      - ./logs/:/app/logs
    network_mode: host
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:3000/actuator/health/"]
      interval: 10s
      timeout: 3s
      retries: 30
    restart: always


  tx:
    container_name: tx
    build:
      context: ./km-tx/
      dockerfile: Dockerfile
    ports:
      - "5004:5004"
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    volumes:
      - ./logs/:/app/logs
    network_mode: host
    restart: always
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:5004/actuator/health/"]
      interval: 10s
      timeout: 3s
      retries: 30




  gateway:
    container_name: gateway
    build:
      context: ./km-gateway/
      dockerfile: Dockerfile
    ports:
      - "9999:9999"
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    volumes:
      - ./logs/:/app/logs
    network_mode: host
    restart: always
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:9999/actuator/health/"]
      interval: 10s
      timeout: 3s
      retries: 30


  manage:
    container_name: manage
    build:
      context: ./km-manage/
      dockerfile: Dockerfile
    ports:
      - "4001:4001"
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    volumes:
      - ./logs/:/app/logs
    network_mode: host
    restart: always
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:4001/actuator/health/"]
      interval: 10s
      timeout: 3s
      retries: 30

  pay:
    container_name: pay
    build:
      context: ./km-pay/
      dockerfile: Dockerfile
    ports:
      - "4009:4009"
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    volumes:
      - ./logs/:/app/logs
    network_mode: host
    restart: always
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:4009/actuator/health/"]
      interval: 10s
      timeout: 3s
      retries: 30



  consult:
    container_name: consult
    build:
      context: ./km-consult/
      dockerfile: Dockerfile
    ports:
      - "4011:4011"
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    volumes:
      - ./logs/:/app/logs
    network_mode: host
    restart: always
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:4011/actuator/health/"]
      interval: 10s
      timeout: 3s
      retries: 30

  ihos:
    container_name: ihos
    build:
      context: ./km-ihos/
      dockerfile: Dockerfile
    ports:
      - "4008:4008"
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    volumes:
      - ./logs/:/app/logs
    network_mode: host
    restart: always
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:4008/actuator/health/"]
      interval: 10s
      timeout: 3s
      retries: 30
    restart: always




  mall:
    container_name: mall
    build:
      context: ./km-mall/
      dockerfile: Dockerfile
    ports:
      - "4088:4088"
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    volumes:
      - ./logs/:/app/logs
    network_mode: host
    restart: always
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:4088/actuator/health/"]
      interval: 10s
      timeout: 3s
      retries: 30


  assets:
    container_name: assets
    build:
      context: ./km-assets/
      dockerfile: Dockerfile
    ports:
      - "4010:4010"
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    volumes:
      - ./logs/:/app/logs
    network_mode: host
    restart: always
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:4010/actuator/health/"]
      interval: 10s
      timeout: 3s
      retries: 30

  pda:
    container_name: pda
    build:
      context: ./km-pda/
      dockerfile: Dockerfile
    ports:
      - "4111:4111"
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    volumes:
      - ./logs/:/app/logs
    network_mode: host
    restart: always
    healthcheck:
      test: ["CMD", "curl" ,"http://127.0.0.1:4111/actuator/health/"]
      interval: 10s
      timeout: 3s
      retries: 30

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值