My project consists of a REST service, which is registered in Eureka, also I use Zuul proxy to manage requests as seen in this image. It runs perfectly on my computer in a local way but when I create a docker container for my service, it doesn't start. The steps I followed:
- I created a Docker container for each service: Eureka server, Zuul API Gateway, the REST service and my Mysql database.
- I get the data of my service from a stored procedure in the database, this conection was tested and it works.
- I start all instances with docker-compose, Eureka and database instances remains up but the REST service instance stops abruptly. Zuul not is implemented yet.
The error:
matriculas-ms_1 | org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.eurekaClient' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.discovery.EurekaClient]: Factory method 'eurekaClient' threw exception; nested exception is java.lang.RuntimeException: Failed to initialize DiscoveryClient!
Here is the docker-compose.yml
version: '3.3'
services:
srclbd:
build: ./srclbd
ports:
- "3307:3306"
expose:
- "3306"
volumes:
- ./srclbd/data:/var/lib/mysql
eureka:
build: ./Eureka
ports:
- "8761:8761"
expose:
- "8761"
matriculas-ms:
build: ./matriculas-ms
ports:
- "3333:3333"
expose:
- "3333"
depends_on:
- srclbd
- eureka
links:
- srclbd
- eureka
environment:
- DATABASE_HOST=srclbd
- EUREKA_HOST=eureka
Eureka's Dockerfile:
FROM java:8
ADD /target/eureka-0.0.1-SNAPSHOT.jar eureka-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","eureka-0.0.1-SNAPSHOT.jar"]
REST service Dockerfile:
FROM java:8
ADD /target/matriculas-service-0.0.1-SNAPSHOT.jar matriculas-service- 0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","matriculas-service-0.0.1-SNAPSHOT.jar","-Xdebug -Xrunjdwp:server=y,transport=dt_socket,suspend=n"]
Here is my project on github
Which is my error?