I had previously built a Docker image of each Spring micro-service, and in the
docker-compose.yml file this is what I did to start them and have some other services being registered by Eureka’s service, by overriding
defaultZone passing the container’s name:
version: '3' services: eureka-discovery: image: eureka-discovery-service:0.0.1 ports: - 8761:8761 zuul-gateway: image: zuul-gateway-service:0.0.1 environment: - eureka.client.serviceUrl.defaultZone=http://eureka-discovery:8761/eureka depends_on: - eureka-discovery ports: - 8765:8765
It worked. Now, I did things a little different, by bind mounting my project into a container for local development:
version: '3.1' services: eureka-discovery-service: container_name: eureka-discovery-service image: openjdk:184.108.40.206-jdk ports: - 8761:8761 volumes: - ./eureka-discovery-service:/usr/src/app working_dir: /usr/src/app command: ./mvnw spring-boot:run zuul-gateway-service: container_name: zuul-gateway-service image: openjdk:220.127.116.11-jdk environment: - eureka.client.serviceUrl.defaultZone=http://eureka-discovery-service:8761/eureka ports: - 8765:8765 volumes: - ./zuul-gateway-service:/usr/src/app working_dir: /usr/src/app command: ./mvnw spring-boot:run depends_on: - eureka-discovery-service
But with things like this,
zuul-gateway-service doesn’t see
eureka-discovery-service like it did before.
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
What changes with it? How to make Eureka discover again?
Source: Docker Questions