Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

  • I am developing on windows 10 enterpise, latest patch
  • java 8
  • sts 4
  • docker to host mariadb, rabbitmq and zipkin (no services run docker)
  • Using spring boot cloud discovery based on Eureka for service discovery

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
like image 836
Michael Schneider Avatar asked Aug 02 '19 03:08

Michael Schneider


People also ask

What is Eureka instance hostname?

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.

How do I turn on spring boot on Eureka client?

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.

What is Eureka server and Eureka client?

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.

What is the default port for Eureka server or the address is changed which of the following properties need to be changed?

Here we're configuring an application port; the default one for Eureka servers is 8761.


2 Answers

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.

like image 92
Harsh Raj Avatar answered Sep 28 '22 10:09

Harsh Raj


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.

like image 41
Paras Girdher Avatar answered Sep 28 '22 11:09

Paras Girdher