I have docker service create a bunch of Eureka clients, but their IP type is inconsistent, sometimes it's containerId and sometimes it's numeric IP address.

And the numeric IP address - I don't really know where they are from - doesn't belong to my public or private IP address. I suppose numeric address comes from overlay network or docker inside.
Has anyone encountered the same problem like me?
Here are my eureka client config snippets.
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_SERVER_ADDRESS}
spring:
application:
name: api
redis:
host: ${server.remote}
port: 6379
boot:
admin:
url: ${ADMIN_ADDRESS}
username: ${security.admin.name}
password: ${security.admin.password}
client:
metadata:
user:
name: ${security.admin.name}
password: ${security.admin.password}
Supplement
I used docker stack deploy to deploy my Eureka server (2 instance aware of each other).
I used docker service create to deploy my Eureka client (STOCK-SERVICE) and feign consumer (API).
All of my instances (server銆乧lient銆乧onsumer) are all under same overlay network.
Hi @kimjuny,
have you tried this?
eureka:
instance:
preferIpAddress: true
This sets the IP as hostname which is, at leased from what I've had learned, a good idea in docker environments.
@doernbrackandre Hi, I've just tried setting preferIpAddress: true, still no luck. I have added some supplement to my question.
Check this out, this fixes my problem.
spring:
cloud:
inetutils:
ignored-interfaces:
- eth0
- eth1
- eth2
- eth3
- lo
Set this to my service-provider and service-consumer configurations, and now they are all using IP address consistently rather than container-id. 馃帀馃帀
So I'm closing this.
Hi @kimjuny Still I am facing the same issue
Eureka Server Configuration look like :
spring.application.name=test-eureka-naming-server
server.port=8001
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.server.enableSelfPreservation=false
eureka.server.eviction-interval-timer-in-ms=1000
Client Configuration
spring.application.name=test-cloud-config-server
server.port=8003
eureka.client.service-url.defaultZone =http://172.17.0.2:8001/eureka
spring.profiles=docker
eureka.instance.prefer-ip-address=true
I put below config in client and server both
spring:
cloud:
inetutils:
ignored-interfaces:
- eth0
- eth1
- eth2
- eth3
- lo
Can you check? There is an issue in configuration or not?
@kimjuny Hello.
Check this issue https://github.com/spring-cloud/spring-cloud-netflix/issues/1820.
May be it will help to you. I wrote a lot there 馃槂.
I was making sure that we will always get container-id using this https://stackoverflow.com/a/45233417/3514300
@kimjuny your configuration might fail if the docker container has more than 4 networks for example eth4 or eth5.
One way of making sure that you always get the hostname is by setting eureka.instance.hostname.
Refer: https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#prefer-ip-address
Most helpful comment
Check this out, this fixes my problem.
Set this to my service-provider and service-consumer configurations, and now they are all using IP address consistently rather than
container-id. 馃帀馃帀So I'm closing this.