简体   繁体   English

Spring Boot,Docker,Discovery eureka

[英]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. 我有两个用例。

  1. I want to start they localy 我想在本地开始
  2. I would like to start they in aws ECS. 我想在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 然后使用随机的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.

相关问题 Spring Boot Eureka微服务发现和注册在Docker中失败 - spring boot Eureka microservice discovery and registration fails in docker Spring 使用 Eureka 和 Docker Swarm 启动管理 - Spring Boot Admin with Eureka and Docker Swarm 使用 Spring Boot 的 Docker 和 Eureka 无法注册客户端 - Docker and Eureka with Spring Boot failing to register clients spring 启动尤里卡与 docker 连接被拒绝 - spring boot eureka with docker gets connection refused 使用 spring 引导在 Docker 中运行 Eureka Server 和 Eureka Client - Running Eureka Server and Eureka Client in Docker using spring boot Spring 启动 Eureka Server Client 在 docker 下抛出连接超时 - Spring boot Eureka Server Client throws connection timeouts under docker Spring启动,获取Docker暴露端口进行eureka注册 - Spring boot, get Docker exposed port for eureka registration Spring引导Eureka在docker swarm中注册了错误的内部docker ip - Spring boot Eureka in docker swarm registering wrong internal docker ip’s 微服务使用Eureka和traefik和docker compose进行服务发现 - Micro services Service discovery using Eureka and traefik with docker compose Spring 启动微服务正在以 pod 名称作为 Kubernetes 集群中的主机名注册到 Eureka - docker 桌面 - Spring boot microservices are getting registered to Eureka with the pod name as the hostname in the Kubernetes cluster - docker desktop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM