docker-compose 编写实战


version: "3"
services:
   servicename:         #docker-compose服务名称 一个主机内的不能重复
       image: bjwl-images-registry-vpc.cn-beijing.cr.aliyuncs.com/xbk/servicename:tags
       container_name: servicename
       hostname: servicename
       #ports:
           #- "serviceport:serviceport"
       volumes:
           - "/data/logs:/logs"
           - "/etc/localtime:/etc/localtime"
       restart: always
       network_mode: "host"
       #environment:
           #PROFILE: q
           #java_options: ''
           #SERVER_PORT: serviceport
           #EUREKA_INSTANCE_URL: eureka_ip
           #EUREKA_SERVICE_URL: http://172.17.205.162:9000/eureka,http://172.17.205.164:9000/eureka
      deploy:
          resources:
              limits:
                cpus: '1'
                memory: '3g'
             reservations:
                cpus: '0.5'
                memory: '3g'
         healthcheck:
             test: "${DOCKER_HEALTHCHECK_TEST:-curl localhost:serviceport/actuator/health}"
             interval: "60s"
             timeout: "3s"
             start_period: "5s"
             retries: 3