如何解决Netflix-zuul 无法在 docker 中注册 eureka api
我有 Eureka 服务器和 zuul 服务器以及其他 3 个微服务。当我从 STS 将这些作为 spring 启动应用程序运行时,这些工作完美。我尝试在 docker 和 zuul 中运行我的 eureca 服务器作为 Spring Boot 应用程序,它也可以完美运行。 但是,当我进行 docker compose 并尝试使用 eureka 注册我的服务和 zuul 时,我从 zuul 收到异常,因为连接已关闭 [未连接]。
我从其他答案中修改了我的 docker-compose 但没有任何效果。 我在 win 10 环境中使用 windows 容器。
Docker-compose.yml 我尝试过端口: - "8761:8761" 也是。
version: '3.6'
services:
netflix-eureka-naming-server:
container_name: eureka-serviceregistry
build:
network: host
context: ./netflix-eureka-naming-server/
dockerfile: ./Dockerfile
restart: always
ports:
- "8761"
networks:
services-network-01:
aliases:
- discovery-server
hostname: discovery-server
netflix-zuul-api-gateway-server:
container_name: gateway
build:
network: host
context: ./netflix-zuul-api-gateway-server
dockerfile: ./Dockerfile
restart: always
ports:
- "8080:8080"
networks:
services-network-01:
aliases:
- zuul-server
depends_on:
- netflix-eureka-naming-server
links:
- "netflix-eureka-naming-server:netflix-eureka-naming-server"
hostname: zuul-server
networks:
services-network-01:
name: services-network-01
driver: nat
尤里卡应用程序.properties
spring.application.name=netflix-eureka-naming-server
server.port=8761
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.server.max-elements-in-peer-replication-pool=0
Zuul 应用程序 .properties
spring.application.name=netflix-zuul-api-gateway-server
server.port=8080
#Eureka Configuration
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.service-url.default-zone=http://discovery-server:8761/eureka
zuul.sensitiveHeaders=
错误 -
2021-02-10 21:04:05.854 WARN [netflix-zuul-api-gateway-server,] 1256 --- [nfoReplicator-0] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution Failed with message: java.net.ConnectException: Connection refused: connect
2021-02-10 21:04:05.854 WARN [netflix-zuul-api-gateway-server,] 1256 --- [nfoReplicator-0] com.netflix.discovery.discoveryClient : discoveryClient_NETFLIX-ZUUL-api-gateway-SERVER/172.24.191.40:netflix-zuul-api-gateway-server:8765 - registration Failed Cannot execute request on any kNown server
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.8.6.jar!/:1.8.6]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.8.6.jar!/:1.8.6]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) ~[eureka-client-1.8.6.jar!/:1.8.6]
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.8.6.jar!/:1.8.6]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.8.6.jar!/:1.8.6]
at com.netflix.discovery.discoveryClient.register(discoveryClient.java:829) ~[eureka-client-1.8.6.jar!/:1.8.6]
at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:104) ~[eureka-client-1.8.6.jar!/:1.8.6]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
2021-02-10 21:04:05.854 WARN [netflix-zuul-api-gateway-server,] 1256 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator : There was a problem with the instance info replicator
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.8.6.jar!/:1.8.6]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.8.6.jar!/:1.8.6]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) ~[eureka-client-1.8.6.jar!/:1.8.6]
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.8.6.jar!/:1.8.6]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.8.6.jar!/:1.8.6]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。