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)
Summary
Everything worked fine until the docker update today, after the docker upgrade
Eureka returns "host.docker.internal" as the hostname for my development box (machine hosting the spring boot cloud services)
This has worked fine until the docker updgrade on windows 10 today.
Any guidance on this one?
------------------------------ Details ----------------------------
"
---------------- 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"
}
I am using windows 10 enterprise for java development.
I use docker-compose to host mariadb, zipkin, and rabbitmq in my dev env on my windows 10 box
I have a multi-project gradle build with 8 spring boot cloud services
One of the services is a spring cloud discovery service hosting Eureke
The other spring cloud services are eureka clients.
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
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).
I updated docker, did a reboot.
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 . . . . . . . . . :
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}
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
You can either set eureka.instance.hostname="your-host-name" for the client in its config to whatever you want it to register with, or try setting eureka.instance.prefer-ip-address=true.
The @EnableEurekaClient annotation makes your Spring Boot application act as a Eureka client. To register the Spring Boot application into Eureka Server we need to add the following configuration in our application. properties file or application. yml file and specify the Eureka Server URL in our configuration.
Eureka Service: looks like when you register a microservice as an Eureka Client, you obtain an Eureka Service registered by an ID. Eureka Server: a server where microservices can register themselves so others can discover them.
Here we're configuring an application port; the default one for Eureka servers is 8761.
I was facing a similar issue where the eureka server was registering the services at host.docker.internal instead of localhost.
The issue in my case was an altered host file at location C:\Windows\System32\Drivers\etc\hosts. I deleted all the lines in the host file and saved it using npp with admin privilege. Restart the server post this change.
Looks like 'Docker Desktop' was changing the hostfile.
Solution for Window 10: You don't have to remove all the lines from hosts files. Just comment this if exists (#192.168.1.4 host.docker.internal) (as we use this when playing with docker) And paste this (127.0.0.1 host.docker.internal) It worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With