I have all of my microservices using Spring Cloud (Config Server, Eureka Server, API Gateway, and the services) working interdependently and running perfectly fine in my local computer. But I am having problem running them in a docker container because I believe Eureka Server and other services not picking up properties from the Config Server.
I was able to run the Config Server in a container without problem at port 8888 but others not. Eureka Server always runs on the default port 8080 even if I specified 8761 in the properties file, then it fails after a few seconds. Below are my docker and properties files.
Here is my Config Server's bootstrap.properties:
server.port = 8888
spring.cloud.config.server.native.searchLocations = file:///${user.home}/config-repo
spring.profiles.active = native
I am referencing to the Config Server from Eureka Server through this:
spring.cloud.config.uri = http://localhost:8888
And here is my Eureka Server's properties:
server.port = 8761
eureka.client.register-with-eureka = false
eureka.client.fetch-registry = false
Here is my Config Server's dockerfile:
FROM alpine-jdk:base
MAINTAINER javaonfly
COPY files/config-service.jar /opt/lib/
RUN mkdir /var/lib/config-repo
COPY config-repo /var/lib/config-repo
ENTRYPOINT ["/usr/bin/java"]
CMD ["-jar", "/opt/lib/config-service.jar"]
VOLUME /var/lib/config-repo
EXPOSE 8888
Here is my Eureka Server's dockerfile:
FROM alpine-jdk:base
MAINTAINER javaonfly
COPY files/eureka-service.jar /opt/lib/
ENTRYPOINT ["/usr/bin/java"]
CMD ["-jar", "/opt/lib/eureka-service.jar"]
EXPOSE 8761
Here is my Docker Compose file:
version: '2.2'
services:
config-service:
container_name: config-service
build:
context: .
dockerfile: Dockerfile-configservice
image: config-service:latest
expose:
- 8888
ports:
- 8888:8888
networks:
- emp-network
volumes:
- config-repo:/var/lib/config-repo
eureka-service:
container_name: eureka-service
build:
context: .
dockerfile: Dockerfile-eurekaservice
image: eureka-service:latest
expose:
- 8761
ports:
- 8761:8761
networks:
- emp-network
networks:
emp-network:
driver: bridge
volumes:
config-repo:
external: true
Hope anyone can help me with this so I can finally see them running in a docker container and I can be able to explore Kubernetes next.