简体   繁体   中英

Spring Boot, Docker, Discovery eureka

I have the following problem.

I have two Springboot services: Service A and Service Discovery Eureka.

And I have two use cases.

  1. I want to start they localy
  2. I would like to start they in aws ECS.

I packed they in the container. And i start the Service A with the random docker port mapping: docker run -p 0: 8080 serviceA

And after that I have the following problem.

Docker Service A registers with docker discovery services with an incorrect port. Service A registers with the port of Spring Boot Application 8080, not the docker port.

How can I tell Service A to register with the port of docker?

Eureka will try to invoke your service in the port defined in the boostrap.yml file or 8080 if none is defined. Therefore, you will need to open data same port mapping in your Docker container:

docker run -p 8080:[the port used your application]

Keep in mind that reading the bootstrap file is the first thing done by Spring at startup.

In case you want to run locally, you can define a profile where Spring Cloud is disabled and the port usage is the typical one (ie defined by the property server.port)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM