Applications not registering to eureka when using docker-compose

后端 未结 2 1847
無奈伤痛
無奈伤痛 2021-01-22 10:53

I took this example https://github.com/paulc4/microservices-demo and I created 3 docker images from it, with the following Dockerfiles:

springdocker-registration:

<
2条回答
  •  独厮守ぢ
    2021-01-22 11:23

    For those who are working with docker-compose and if in your services yml file you have the following:

    eureka:
      client:
        serviceUrl:
          # Will get overridden in docker-compose
          defaultZone: http://localhost:1111/eureka
    

    You can override this in your docker-compose file like below while running docker-compose up

    version: "3.3"
    services:
    
     # Other services registered above
    
     web:
      image: springdocker-web
      environment: 
       # Important for clients to register with eureka
       - eureka.client.serviceUrl.defaultZone=http://registration:8761/eureka/
      ports:
       - "3333:3333"
      depends_on:
       - registration
       - accounts
      links:
       - registration
    

    Tested on Docker version 19.03.8

提交回复
热议问题