title: How to configure and run Eureka Server, Microservices (Eureka Client), Zuul inside separate docker containers?
body: <p>I am a newbie in Spring Boot and Docker. 
  Written the below microservices.</p>
  
  <ol>
  <li><strong>User Registration Service</strong>: Create users in the MySql database and also interacts with "Search and Delete Service" using Rest Template and its Eureka Client. GitHub <a href="https://github.com/git4suvendu/UserRegistrationMicroservice/tree/multiInstanceMicroservice" rel="nofollow noreferrer">link</a></li>
  <li><strong>User Search and Delete Service</strong>: Search and Delete from MySql database and its Eureka Client. GitHub <a href="https://github.com/git4suvendu/UserSearchDeleteMicroservice" rel="nofollow noreferrer">Link</a></li>
  <li><strong>Eureka Server</strong>: Used for service discovery. GitHub <a href="https://github.com/git4suvendu/UserRegistrationEurekaServer" rel="nofollow noreferrer">Link</a></li>
  <li><strong>Zuul Server</strong>: Used as an API Gateway and its Eureka Client. GitHub <a href="https://github.com/git4suvendu/ZuulAPIGateway" rel="nofollow noreferrer">Link</a></li>
  </ol>
  
  <p>I have used "Spring Boot STS" to develop the services. Also used "Spotify" dependency to build the docker images.</p>
  
  <p>I am able to run all the services from STS on localhost (windows) and everything is working fine. All the three services mentioned before are getting registered in Eureka server. </p>
  
  <p>But everything stopped working when I choose to dockerize the services. I have created four docker images of the four services. </p>
  
  <p><strong>Problem:</strong> Ran the Eureka server and "User Registration Service" in two sperate containers but the service is not getting registered with Eureka. In fact none of the services is getting registered with Eureka.</p>
  
  <p><strong>What I did:</strong></p>
  
  <h2>Try 1:</h2>
  
  <pre><code>Ran the Eureka server and client using below commands:
  </code></pre>
  
  <blockquote>
    <p>docker run --rm -it --name eurekaserver-container -p 8761:8761
    eurekaserver-alpine-linux</p>
    
    <p>docker run --rm -it -d --name user-registration-container -p 8081:8081
    user-registration</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/SjrdZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SjrdZ.jpg" alt="enter image description here"></a></p>
  
  <p>It seems Eureka Client (User Registration Service) is not able to find Eureka server. What I found, Eureka server is running within a container with different IP (172.0...) and Eureka client is not able to connect the server.</p>
  
  <h2>Try 2:</h2>
  
  <p>Ran the Eureka server and client using below commands. Tried to link the two containers (Eureka Server and Client):</p>
  
  <blockquote>
    <p>docker run --rm -it --name eurekaserver-container -p 8761:8761
    eurekaserver-alpine-linux</p>
    
    <p>docker run --rm -it -d --name user-registration-container -p 8081:8081
    --link eurekaserver-container:eureka-server user-registration</p>
  </blockquote>
  
  <p>This also didn't work.</p>
  
  <p><a href="https://i.stack.imgur.com/How9N.jpg" rel="nofollow noreferrer">Try 2 Error</a></p>
  
  <h2>Try 3:</h2>
  
  <p>Ran the Eureka server and client using below commands. Tried to pass the host name to Eureka image, so that Client can find the Eureka server using host name. Also linked the two containers.</p>
  
  <blockquote>
    <p>docker run --rm -it -d  --name eurekaserver-container -h 
    discovery-eurekaserver.com  -p 8761:8761 eurekaserver-alpine-linux
    /bin/bash</p>
    
    <p>docker run --rm -it -d  --name user-registration-container -p
    8081:8081 --link eurekaserver-container:eureka-server
    user-registration</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/MAdXL.jpg" rel="nofollow noreferrer">Try 3 Error</a></p>
  
  <p>This also didn't work.</p>
  
  <p><strong>Can anyone please help me to understand what am I doing wrong?</strong> Whatever I have tried, Eureka clients are not able to register with Eureka server when running in different containers.</p>
  
  <p>My objective is to run the services (Eureka Server, Application Services etc.) in different containers and all the services will register with Eureka server, so that I can call APIs from Postman or SOAP UI.</p>