title: Use Eureka despite having random external port of docker containers
body: <p>I am writing an application that is composed of a few spring boot based microservices with a zuul based reverse proxy in the front-</p>
  
  <p>It works when I start the services on my machine, but for server rollout I'd like to use docker for the services, but this seems not to be possible right now.</p>
  
  <p>Normally you would have a fixed "internal" port and randomized ports at the outside of the container. But the app in the container doesn't know the outside port (and IP).</p>
  
  <p>The Netflix tools match what I would want to write an efficient microservice architecture and conceptually I really like docker. 
  As far as I can see it would be very troublesome to start the container, gather the outside port on the host and pass it to the app, because you can't simply change the port after the app is started.</p>
  
  <p>Is there any way to use eureka with docker based clients?</p>
  
  <p>[Update]
  I guess I did a poor job explaining the problem. So maybe this clarifies it a bit more:</p>
  
  <p>The eureka server itself can run in docker, as I have only one and the outside port doesn't matter. I can use the link feature to access it from the clients.</p>
  
  <p>The problem is the URL that the clients register themselves with.
  This is for example <a href="https://localhost:8080/" rel="noreferrer">https://localhost:8080/</a> but due to dynamic port assignment it is really only accessible via <a href="https://localhost:54321/" rel="noreferrer">https://localhost:54321/</a></p>
  
  <p>So eureka will return the wrong URL for the services.</p>
  
  <p><strong>UPDATE</strong>
  I have updated my answer below, so have a look there.</p>