擺置微服務,老是java -jar server.jar,顯得太low。docker助力下吧,不料倒騰良久。。。java
spring: application: name: mall-server eureka: # 關閉自我保護模式 # eureka.server.enable-self-preservation: false client: healthcheck: enabled: true service-url: defaultZone: http://slave1:8761/eureka/,http://slave2:8762/eureka/,http://slave3:8763/eureka/ info: app: name: ${spring.application.name} description: Eureka 註冊中心 version: 1.0.0 --- spring: profiles: slave1 server: port: 8761 eureka: instance: hostname: slave1 --- spring: profiles: slave2 server: port: 8762 eureka: instance: hostname: slave2 --- spring: profiles: slave3 server: port: 8763 eureka: instance: hostname: slave3
version: '3.5' services: slave1: container_name: s1 image: mall/server:1.0.0 networks: - mall-server-net ports: - 8761:8761 environment: - SPRING_PROFILES_ACTIVE=slave1 slave2: container_name: s2 image: mall/server:1.0.0 networks: - mall-server-net ports: - 8762:8762 environment: - SPRING_PROFILES_ACTIVE=slave2 slave3: container_name: s3 image: mall/server:1.0.0 networks: - mall-server-net ports: - 8763:8763 environment: - SPRING_PROFILES_ACTIVE=slave3 networks: mall-server-net: name: mall-server-net driver: bridge