spring boot cloud eurka​​ windows 10 eurkea在最新的docker升级后返回host.docker.internal作为客户端主机名 [英] spring boot cloud eurka windows 10 eurkea returns host.docker.internal for client host name after latest docker upgrade

查看:125
本文介绍了spring boot cloud eurka​​ windows 10 eurkea在最新的docker升级后返回host.docker.internal作为客户端主机名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring Boot Cloud Disovery 问题,Windows 10 上 docker 升级后 Eureka 主机名有问题.(注意:docker 不托管 spring 服务,只有 mariadb、rabbitmq 和 zipkin)

Spring Boot Cloud Disovery Question, Problem with Eureka hostname after docker upgrade on windows 10. (Note: docker is not hosting spring services, just mariadb, rabbitmq, and zipkin)

总结

  • 我正在 Windows 10 企业版上开发,最新补丁
  • Java 8
  • sts 4
  • docker 来托管 mariadb、rabbitmq 和 zipkin(没有服务运行码头工人)
  • 使用基于 Eureka 的 spring boot 云发现服务发现

一切正常,直到今天 docker 更新,在 docker 升级之后

Everything worked fine until the docker update today, after the docker upgrade

Eureka 返回host.docker.internal"作为我的开发箱(托管 Spring Boot 云服务的机器)的主机名

Eureka returns "host.docker.internal" as the hostname for my development box (machine hosting the spring boot cloud services)

这一直很好,直到今天 Windows 10 上的 docker 升级.

This has worked fine until the docker updgrade on windows 10 today.

对此有任何指导吗?

------------------------------ 详情----------------------------

------------------------------ Details ----------------------------

"

---------------- spring 版本 ----------

---------------- Versions of spring ----------

buildscript {
    ext {
        springCloudVersion = "Greenwich.SR1"
        springBootVersion = "2.1.5.RELEASE"
        springRetryVersion = "1.2.4.RELEASE"
        lombokVersion = "3.6.4"
        mySqlConnectorVersion = "8.0.15"
        springBootAdminVersion = "2.1.5"

    }

<小时>

我正在使用 Windows 10 Enterprise 进行 Java 开发.


I am using windows 10 enterprise for java development.

我使用 docker-compose 在我的 Windows 10 机器上的开发环境中托管 mariadb、zipkin 和 rabbitmq

I use docker-compose to host mariadb, zipkin, and rabbitmq in my dev env on my windows 10 box

我有一个包含 8 个 spring boot 云服务的多项目 gradle 构建

I have a multi-project gradle build with 8 spring boot cloud services

其中一项服务是托管 Eureke 的 Spring Cloud Discovery 服务

One of the services is a spring cloud discovery service hosting Eureke

其他 spring 云服务是 eureka 客户端.

The other spring cloud services are eureka clients.

直到今天,一切正常1)先启动Eureka spring boot云服务2) eclipse启动客户端的其他spring boot云服务,注册并查询spring cloud discovery客户端代码,获取其他服务的URL

Until today, everything worked 1) Eureka spring boot cloud services are started first 2) Other spring boot cloud services that are clients of the eclipse startup, register and query the spring cloud discovery client code to obtain the URL of the other services

今天,windows 10 的最新 docker 推送出来了,我安装了(我一直在通过其他几个 docker 更新开发这个应用).

Today, The latest docker for windows 10 was pushed out, and I installed it (I have been developing this app through several other docker updates).

我更新了 docker,重新启动了.

I updated docker, did a reboot.

重启后,Eureka 服务器返回host.docker.internal"作为 URL 中的主机名,而不是 http:/mymachinename:8080

After the reboot, The Eureka server is returning "host.docker.internal" as the hostname in the URL instead of http:/mymachinename:8080

升级前我没有网络数据,但现在有了

I don't have the network data before the upgrade, but now it is

U:\>ipconfig

Windows IP Configuration


Ethernet adapter vEthernet (DockerNAT):

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 10.0.75.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : net.FOO.BAR.com
   IPv4 Address. . . . . . . . . . . : 146.122.145.71
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 146.122.145.1

Ethernet adapter vEthernet (Default Switch):

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 172.28.74.49
   Subnet Mask . . . . . . . . . . . : 255.255.255.240
   Default Gateway . . . . . . . . . :

<小时>

我的客户端 application.properties 文件是:


My client application.properties file is:

eureka.client.serviceUrl.defaultZone= http://${ci2.srvhost}:8761/eureka/
eureka.instance.hostname=${ci2.srvhost}
spring.cloud.client.hostname=${ci2.srvhost}

<小时>

服务器应用程序.property 文件


Server application.property file

server.port=8761


eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false

logging.level.com.netflix.eureka=OFF
logging.level.com.netflix.discovery=OFF


Standard reboot after docker updated



The expected URL from discovery is

http://mymachine:8091

returned value after docker upgrade

http://host.docker.internal:8091

推荐答案

感谢 Windows 上主机文件的提示

Thanks for the tip on the host file on windows

我发现 docker 在主机文件中为 host.docker.internal 和 gateway.docker.internal 添加了别名.

I found that docker adds aliases in the host file for host.docker.internal and gateway.docker.internal.

我猜 Eureka 从 IP 中查找主机并返回 host.docker.internal.

I am guessing that Eureka does a host lookup from the IP and host.docker.internal is returned.

我不是主机文件方面的专家,但我为我的 IP 添加了实际主机名的别名(注意:我们使用静态 IP).执行此操作后,docker 在重新启动时没有更改我的主机文件,并且 ip->host 的反向查找现在返回我的机器名称而不是 host.docker.internal

I am not an expert at hosts files, but I added an alias for my actual host name to my IP (note: we use static ip's). After doing this, docker did not change my host file on reboot and the reverse lookup of the ip->host now returns my machine name instead of host.docker.internal

------------------ modified hosts file for windows

#I added an alias from my machine name to the IP before the docker added aliases
#
146.122.145.71 mymachine.net.foo.com
# Added by Docker Desktop
146.122.145.71 host.docker.internal
146.122.145.71 gateway.docker.internal

这篇关于spring boot cloud eurka​​ windows 10 eurkea在最新的docker升级后返回host.docker.internal作为客户端主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆