Exception trying to connect a service in a docker container to eureka in a docker container

Published

I am trying to connect a eureka client in one docker container to a eureka server in another docker container.

I am trying to connect via the service name set up in my

In my docker docker-compose.yaml

services:
 eureka-server:
   image:  eurekaservice
   hostname: eureka-server
   container_name: eurekahost
   ports:
     - "8761:8761"

In my eureka properties file I have

spring.application.name=eureka-service
server.port=8761

eureka.client.registerWithEureka = false
eureka.client.fetchRegistry = false
eureka.instance.hostname=eurekahost
eureka.client.service-url.defaultZone=http://eurekahost:8761/eureka

in my eureka client properties file I have

server.port=8080
spring.application.name=user-service

eureka.client.registerWithEureka = true
eureka.client.fetchRegistry = true
eureka.client.serviceUrl.defaultZone  = http://eurekahost:8761/eureka
eureka.client.instance.preferIpAddress = false
eureka.instance.hostname= eurekahost

I run the Eureka with docker-compose up

Then i start up the client service with

docker run -p 8083:8080 bankuser

i get the following exception

Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8761 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
       at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
       at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
       at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)

Cant figure out what I am missing.

Source: Docker Questions

Published
Categorised as docker, docker-compose, netflix-eureka Tagged , ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq