hpxue13
hpxue13

Reputation: 69

"prefer-ip-address" of Eureka client not work in docker container

I have a Spring Cloud Eureka client instance running inside docker, and I would like the client to register itself the host's IP address rather than the container's hostname to the Eureka server, so I set eureka.instance.ip-address: xx.xx.xx.xx and eureka.instance.prefer-ip-address: true to the client's application.yml, but that does not work, it still registers the container's hostname to the server, any help is appreciated!

spring:
  application:
    name: uaa-service
server:
  port: 8799

eureka:
  service-url:
    defaultZone: https://XX.YY.ZZ/eureka/
  instance:
    prefer-ip-address: true
    ip-address: xx.xx.xx.xx

screenshot My Spring Boot version is 2.0.0.RELEASE and Spring Cloud being Finchley.M9.

Upvotes: 3

Views: 7404

Answers (2)

Petter
Petter

Reputation: 338

I'm using the same version of spring-boot and have a similar problem

But I think you are confusing IP address with the instance ID.

See this link: https://github.com/spring-cloud/spring-cloud-netflix/issues/1646#issuecomment-275121055

When you hover the mouse over the link or click on it, does it show the right IP-Address?

Anyway, I have two applications, one using spring-boot 1.5 where this property works.

With the 2.0 version the application always use the machine IP, instead what I informed in the eureka.instance.ip-address.


Edit > I reported a bug here: https://github.com/spring-cloud/spring-cloud-netflix/issues/2878

Upvotes: 1

Vamsi
Vamsi

Reputation: 684

Give this in your spring service

spring:
  application:
    name: uaa-service
  cloud:
    inetutils:
      ignored-interfaces:
        - eth0
        - eth1
        - eth2
        - eth3
        - lo

Taken from this

Upvotes: 1

Related Questions