title: Netflix Eureka Server and Client instance registration issue with Docker swarm
body: <p>We are trying to deploy Netflix Eureka Server on Docker container which is a Spring Boot application. We are deploying it as a docker service with Docker swarm for container orchestration.
  Everything works fine when we directly create the container and run the application. 
  Eureka server registers all the client application with correct IP addresses.
  But when we create and deploy it as docker service it registers the application with the wrong IP address.</p>
  
  <p>We have tried below solution as per spring documentation, updated property values in our configuration files.</p>
  
  <pre>
  <code>
  spring: 
     cloud:
       inetutils:
         ignoredInterfaces:
            - docker0
            - veth.*
  
  eureka:
    instance:
      preferIpAddress: true
  </code>
  </pre>
  
  <p>Tried these solutions as well: </p>
  
  <p><a href="https://github.com/spring-cloud/spring-cloud-netflix/issues/1820" rel="nofollow noreferrer">https://github.com/spring-cloud/spring-cloud-netflix/issues/1820</a></p>
  
  <p><a href="https://github.com/spring-cloud/spring-cloud-netflix/issues/2084" rel="nofollow noreferrer">https://github.com/spring-cloud/spring-cloud-netflix/issues/2084</a></p>
  
  <p>While we run the docker service, the container gets assigned one IP address lets say 172.16.1.3 and service started inside docker gets assigned new IP address 172.16.1.4, because of this issue client application registers its self with container's IP into Eureka server. But it is accessible with 172.16.1.4.</p>
  
  <p>So why running docker as service assigns two IP addresses?</p>
  
  <p><a href="https://i.stack.imgur.com/LErrN.png" rel="nofollow noreferrer">Here Eureka server is running on 10.255.53.172 IP address but as we can see in the second image it shows different IP in Instance Info</a></p>
  
  <p><a href="https://i.stack.imgur.com/mOrp3.png" rel="nofollow noreferrer">Eureka instance is registered with containers IP but it's accessible with its service IP in the network</a></p>