spring boot cloud eurka windows 10 eurkea returns host.docker.internal for client host name after latest docker upgrade spring boot cloud eurka windows 10 eurkea returns host.docker.internal for client host name after latest docker upgrade docker docker

spring boot cloud eurka windows 10 eurkea returns host.docker.internal for client host name after latest docker upgrade


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.


It the application.properties file for each eureka client , I added/changed

------------------ client

......ci2.srvhost = my hostname#to find this list,run ipconfig in command promptspring.cloud.inetutils.preferredNetworks=146.122,10.0eureka.client.serviceUrl.defaultZone= http://${ci2.srvhost}:8761/eureka/eureka.instance.hostname=${ci2.srvhost}spring.cloud.client.hostname=${ci2.srvhost}

-------------------- eureka server application.property--------------------

# host to set of ci2 servicesci2.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 dockerspring.cloud.inetutils.preferredNetworks=146.122,10.0

-------------------- standard config, should not need to change below -------------------

server.port=8761eureka.client.register-with-eureka=falseeureka.client.fetch-registry=falseeureka.instance.hostname=${ci2.srvhost}eureka.instance.prefer-ip-address=truelogging.level.com.netflix.eureka=OFFlogging.level.com.netflix.discovery=OFFserviceUrl.defaultZone= http://${eureka.instance.hostname}:${server.port}/eureka/


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 Desktop146.122.145.71 host.docker.internal146.122.145.71 gateway.docker.internal