'Docker container can not fetch configuration from bitbucket
I have a EurekaService and a CloudConfigService (I have other 3 services; but let's focus on the CloudConfigService).
CloudConfigService looks like this -
@EnableEurekaClient
@EnableConfigServer
@SpringBootApplication
public class CloudConfigServiceApplication {
public static void main(String[] args) {
SpringApplication.run(CloudConfigServiceApplication.class, args);
}
}
application.yml -
server:
port: 9296
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: https://[email protected]/erfan_ahmed/config-server-erfan.git
clone-on-start: true
default-label: master
This is how the application.yml of ../config-server-erfan.git looks like -
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://eureka:8761/eureka/
instance:
hostname: eureka
Dockerfile-
FROM openjdk:8-jdk-alpine
#ARG JAR_FILE=target/*.jar
COPY /build/libs/cloud-config-service-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
After building image out of it, when I run the container using following command -
docker run -d --name cloud -p 9296:9296 --network my-network cloud
I get the following error -
c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/}, exception=I/O error on GET request for "http://localhost:8761/eureka/apps/": Connect to localhost:8761 [localhost/127.0.0.1] failed: Connection refused (Connection refused); nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8761 [localhost/127.0.0.1] failed: Connection refused (Connection refused) stacktrace=org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8761/eureka/apps/": Connect to localhost:8761 [localhost/127.0.0.1] failed: Connection refused (Connection refused); nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8761 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
Instead of hitting http://eureka:8761/eureka/, CloudConfig always send get request to localhost:8761. Thus causing the error.
Update 1
I found out that, from inside the container CloudConfig can not fetch config form git - https://[email protected]/erfan_ahmed/config-server-erfan.git. That's why it falls back to default localhost.
I put the config from git into the application.yml file and it works.
So, why it can't fetch config from git url?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
