[英]Spring Boot, Docker, Discovery eureka
I have the following problem. 我有以下问题。
I have two Springboot services: Service A and Service Discovery Eureka. 我有两个Springboot服务:服务A和服务发现Eureka。
And I have two use cases. 我有两个用例。
I packed they in the container. 我把它们装在容器中。 And i start the Service A with the random docker port mapping:
docker run -p 0: 8080 serviceA
然后使用随机的docker端口映射启动服务A:
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.
Docker服务A使用错误的端口向Docker发现服务注册。 Service A registers with the port of Spring Boot Application 8080, not the docker port.
服务A向Spring Boot Application 8080的端口注册,而不是docker端口注册。
How can I tell Service A to register with the port of docker? 如何告诉服务A向docker端口注册?
Eureka will try to invoke your service in the port defined in the boostrap.yml
file or 8080 if none is defined. Eureka将尝试在
boostrap.yml
文件或8080(如果未定义)中定义的端口中调用您的服务。 Therefore, you will need to open data same port mapping in your Docker container: 因此,您将需要在Docker容器中打开相同端口映射的数据:
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. 请记住,读取启动文件是Spring在启动时要做的第一件事。
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) 如果要在本地运行,则可以定义一个配置文件,其中禁用了Spring Cloud,并且端口使用情况是典型的(即,由属性server.port定义)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.