I’m trying to implement an example of Spring Cloud with its all services running in Docker.
I cannot register any service to eureka server as eureka server throws a connection issue in Docker.
When I show the logs of eureka server through this command (docker logs ), I got the error.
Here is the error shown below.
Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eu
reka/}, exception=java.net.ConnectException: Connection refused (Connection refused) stacktrace=com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection
refused (Connection refused)
How can I fix that?
Here is eureka server code snippets of docker-compose.yml shown below.
services:
eurekaserver:
image: eurekaserver
ports:
- "8761:8761"
build:
context: ./discoveryserver
dockerfile: Dockerfile
environment:
CONFIGSERVER_URI: "http://configserver:9191"
CONFIGSERVER_PORT: "9191"
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: "http://eurekaserver:8761/eureka/"
EUREKASERVER_PORT: "8761"
WAIT_HOSTS: configserver:9191
depends_on:
configserver:
condition: service_started
networks:
- backend
networks:
backend:
driver: bridge
volumes:
db-data:
Here is application.properties of eureka server shown below.
spring.application.name=discovery-server
eureka.instance.hostname=eurekaserver
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://eurekaserver:8761/eureka/
server.port=8761
logging.level.org.springframework.cloud.commons.util.InetUtils=TRACE
Here is the project link : Link