Tech Me More

To quench our thirst of sharing knowledge about our day to day experience & solution to techincal problems we face in our projects.

Advertise with us !
Send us an email at

Wednesday, April 22, 2020

How to run netflix eureka with one micro-service app in docker-container using docker-compose

Distributed systems are the need of the current time. From a faster, independent, resilient, highly available application it is not only necessary to adapt to newer technologies to build application logic but deploying them fast is also a core use case.

Spring boot is a highly used framework for developing microservices in the Java ecosystem. With dockers & Kubernetes it is also easy to deploy them anywhere. 

In this post, I will explain how can netflix-eureka and the microservice app communicate with each other in a container environment. 

For this post, I am using two images. 
  • Netflix-eureka : image for Netflix-eureka server listening on port 8762
  • Support-System: A simple microservice application running on default port 8080

for communication with netflix-eureka we need to provide netflix eureka.client.serviceUrl.defaultZone=http://eureka-server:8762/eureka property in our application, so that it understands where the netflix eureka service is running. 

Having it hard coded is a problem and it is discouraged for the stateless purpose. How do we solve this problem when both the applications are running in different containers. 

To solve the above problem we use the docker-compose and link two services together. 


    image: devakash/eureka:latest
      - '80:8762'
    restart: always
    image: devakash/supportsystem:latest
      - '8080:8080'
        - eureka.client.serviceUrl.defaultZone=http://eureka-server:8762/eureka
        - email.password=Password
        - eureka-server
    restart: always

in the above file please notice the link key. Here we are linking our micro-service to eureka-server. Also, notice the defaultZone environment variable where in place of IP we are using the name of the container such as eureka-server which is nothing but an identifier for netflix-eureka server. 

Netflix-eureka default port is 8761 but we can change it using the below setting in file of netflix-eureka microservice application. 


eureka.client.serviceUrl.defaultZone: http://localhost:${server.port}/eureka/

for more details please refer:

No comments: