title: Springboot client unable register with Eureka using Docker container id
body: <p>I have several microservices running in Docker Data Center. I have the same Eureka configuration across the services/applications. But some of the applications are registering with their <code>eth0</code> IP address instead of the container ID. </p>
  
  <p>I have tried setting the <code>preferIpAddress</code> as <code>false</code> but it is not enforcing all the time.</p>
  
  <p>There is no pattern. The same service which registers with container ID during the previous deployment gets registered with IP the other time. I want my services to register always with its container id. Is there a way to enforce it or am I missing something?</p>
  
  <p>Note: I have also cleared all the old docker images from the registry, deployment nodes and tried from the scratch as well.</p>
  
  <p>Eureka Server Config:</p>
  
  <pre><code>eureka:
    instance:
      hostname: discovery
    client:
      registerWithEureka: false
      fetchRegistry: false
      serviceUrl:
        defaultZone: http://${eureka.instance.hostname}:8761/eureka/
  </code></pre>
  
  <p>Microservices client config (It is same across all the microservices)</p>
  
  <pre><code>eureka:
    client:
      healthcheck:
        enabled: true
      serviceUrl:
        defaultZone: http://discovery:8761/eureka/
    instance:
      preferIpAddress: false
      metadataMap:
        instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${random.value}}}
  </code></pre>
  
  <p>Eureka Dashboard Snapshot:
  <a href="https://i.stack.imgur.com/wlBLF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wlBLF.png" alt="enter image description here"></a></p>