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
Thanks for the tip on the host file on windows
I found that docker adds aliases in the host file for host.docker.internal and gateway.docker.internal.
I am guessing that Eureka does a host lookup from the IP and host.docker.internal is returned.
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