Search code examples
spring-bootdocker-swarmnetflix-eurekaspring-cloud-netflix

Spring boot Eureka in docker swarm registering wrong internal docker ip's


Docker nodes are registering with inter ip's in springboot-eureka My conf is as follows 1. Spring-boot eureka deployed to swarm (1 node) 2. Created spring-boot client containers (2nodes) and registering with eureka

The above containers are deployed as separate deployments, and the client conf is as follows

eureka:
  instance:
    prefer-ip-address: true
  client:
    registerWithEureka: true
    fetchRegistry: true
    serviceUrl:
      defaultZone: http://eureka-server-address/eureka/
    healthcheck:
       enabled: true
Spring:
  cloud:
    inetutils:
      ignored-interfaces:
      - eth0
      - eth1
      - eth2
      - eth3
      - lo

the ip's come as 172.1.0.1 instead of real-external ip's. and docker containers fail to connect each other with the real ip's.

docker-compose network_mode: bridge


Solution

  • Update:- The swarm functions in a different way we think it would. 1. The ip's are docker's internal network distributions which is what we know 2. The entire swarm itself is not a bignetwork to work internally (new lesson) 3. We need to create a new network inside swarm for the containers to talk to each other (known + new lesson ..yes got confused)

    For people who are searching for an answer, Please research for docker swarm networking options and create 2 networks 1 for internal and 1 for external traffic and assign them to the containers in your docker-compose). I was able to get it work for my POC but it tend to be hard for going to do in the enterprise scale.