gpt4 book ai didi

docker - Spring Boot Docker com.netflix.discovery.shared.transport.TransportException:无法在任何已知服务器上执行请求

转载 作者:行者123 更新时间:2023-12-02 20:04:33 24 4
gpt4 key购买 nike

这是我的Eureka Server 应用程序。property

# set port
server.port=8761
# no need to register the server with the server
eureka.client.register-with-eureka=false
# don't need a local copy of the registry
eureka.client.fetch-registry=false
Eureka服务器dockerfile
FROM openjdk:8
ADD target/eureka-service.jar eureka-service.jar
EXPOSE 8761
ENTRYPOINT ["java", "-jar", "eureka-service.jar"]
Eureka Client应用程序。属性
eureka.client.serviceUrl.defaultZone= http://localhost:8761/eureka/
eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true
Eureka客户端dockerfile
FROM openjdk:8
ADD target/foo.jar foo.jar
EXPOSE 8971
ENTRYPOINT ["java", "-jar", "foo.jar"]
Eureka服务器用@EnableEurekaServer注释,Eureka客户端用@EnableEurekaClient注释
客户端已成功向EurekaServer注册,并且一切正常。但是当我尝试使用以下方法在Docker中运行它时
Docker-Compose.yml
版本:“2.0”
services:
foo-service:
build: foo/
ports:
- "8761:8761"

bar-service:
build: bar/
ports:
- "8971:8971"
客户端无法向服务器注册。并低于stacktrace。
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
| at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111) ~[eureka-client-1.6.2.jar!/:1.6.2]
| at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.6.2.jar!/:1.6.2]
| at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) ~[eureka-client-1.6.2.jar!/:1.6.2]
| at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.6.2.jar!/:1.6.2]
| at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.6.2.jar!/:1.6.2]
| at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:798) ~[eureka-client-1.6.2.jar!/:1.6.2]
| at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:104) [eureka-client-1.6.2.jar!/:1.6.2]
| at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_171]
| at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_171]
| at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_171]
| at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_171]
| at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_171]
| at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_171]
| at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
我真的是Docker的新手,有什么帮助吗?

最佳答案

dockerfileEurekaServer修改为:

FROM openjdk:8
ADD target/eureka-service.jar eureka-service.jar
EXPOSE 8761
ENTRYPOINT java -jar Eureka-0.0.1-SNAPSHOT.jar eureka

dockerfileEurekaClient修改为:
FROM openjdk:8
ADD target/foo.jar foo.jar
EXPOSE 8971
ENTRYPOINT java -jar foo.jar foo

EurekaClient的属性文件中,修改此属性
eureka.client.serviceUrl.defaultZone=http://eureka:8761/eureka

现在,分别为两个应用程序构建镜像。
docker-compose.yml中,您将需要添加一些配置以将客户端与服务器链接。修改后的docker-compose如下所示:
version: "3"
services:
eureka:
image: eureka:latest
ports:
- "8761:8761"
networks:
- webnet
noob:
image: foo:latest
ports:
- "8971:8971"
networks:
- webnet

networks:
webnet:

干杯!

关于docker - Spring Boot Docker com.netflix.discovery.shared.transport.TransportException:无法在任何已知服务器上执行请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50840249/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com