Spring Boot Cloud Disovery问题,在windows 10上进行码头升级后,Eureka主机名的问题(注意: docker没有承载spring服务,只有mariadb、rabbitmq和zipkin)
摘要
在码头升级之后,直到今天码头更新之前,一切都很好。
Eureka返回"host.docker.internal“作为我的开发框的主机名(承载春季引导云服务的机器)
直到今天,码头工人在windows 10上提升了等级,这一切都很顺利。
对这件有什么指导吗?
-细节
“
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企业进行java开发。
在windows 10框的dev env中,我使用docker-compose托管mariadb、zipkin和rabbitmq。
我有一个带有8 spring引导云服务的多项目级构建。
其中一个服务是包含Eureke的spring云发现服务。
其他春季云服务是eureka客户端。
直到今天,一切都正常运行1) Eureka spring引导云服务首先启动,2)另一种春季启动云服务,即eclipse启动的客户端,注册和查询spring云发现客户端代码,以获得其他服务的URL。
今天,windows 10的最新插件被推开了,我安装了它(我一直在通过其他几个码头更新来开发这个应用程序)。
我更新了码头,重新启动了。
重新启动后,尤里卡服务器将返回"host.docker.internal“作为URL中的主机名,而不是http:/mymachinename:8080
升级前我没有网络数据,但现在是
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文件是:
eureka.client.serviceUrl.defaultZone= http://${ci2.srvhost}:8761/eureka/
eureka.instance.hostname=${ci2.srvhost}
spring.cloud.client.hostname=${ci2.srvhost}服务器application.property文件
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发布于 2020-08-06 12:30:53
谢谢您在windows主机文件上的提示。
我发现docker在主机文件中为host.docker.internal和gateway.docker.internal添加别名。
我猜尤里卡会从IP进行主机查找,并返回host.docker.internal。
我不是主机文件方面的专家,但我在IP中添加了我的实际主机名的别名(注意:我们使用静态ip)。完成此操作后,docker在重新启动时没有更改我的主机文件,ip->主机的反向查找现在返回我的计算机名,而不是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发布于 2020-01-27 11:47:06
我面临着一个类似的问题: eureka服务器正在host.docker.internal而不是本地主机注册服务。
在我的例子中,问题是C:\Windows\System32 32\Driver\etc\ host位置上的一个修改过的主机文件。我删除了主机文件中的所有行,并使用带有管理权限的npp保存它。重新启动服务器发布此更改。
看起来'Docker Desktop‘正在更改主机文件。
发布于 2019-08-02 17:28:15
它是每个eureka客户端的application.properties文件,我添加了/更改了
-客户
......
ci2.srvhost = my hostname
#to find this list,run ipconfig in command prompt
spring.cloud.inetutils.preferredNetworks=146.122,10.0
eureka.client.serviceUrl.defaultZone= http://${ci2.srvhost}:8761/eureka/
eureka.instance.hostname=${ci2.srvhost}
spring.cloud.client.hostname=${ci2.srvhost}# host to set of ci2 services
ci2.srvhost = ${COMPUTERNAME}
# on windows 10 boxes, running docker, we have to include preferred networks,
# this is not needed on linux, or windows boxes not running docker
spring.cloud.inetutils.preferredNetworks=146.122,10.0server.port=8761
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.instance.hostname=${ci2.srvhost}
eureka.instance.prefer-ip-address=true
logging.level.com.netflix.eureka=OFF
logging.level.com.netflix.discovery=OFF
serviceUrl.defaultZone= http://${eureka.instance.hostname}:${server.port}/eureka/https://stackoverflow.com/questions/57319678
复制相似问题