How to setup connections between Docker Containers

31 Views Asked by At

this is my first time using docker so probably I have missed something.

I have one spring multi-module maven project composed by two maven modules:

hyperbank-config-provider
hyperbank-accounts

hyperbank-config-provider contains all the configuration so is the first one that has to be runned, so hyperbank-accounts can be able to retrieve the necessary configurations using rest call to hyperbank-config-provider

I have created the docker image for both modules.

I have runned hyperbank-config-provider docker image using:

docker run -d -p 8888:8888 --name hyperbank-config-provider hyperbank-config-provider:1.0.0

and is up and running

then I have runned the hyperbank-accounts docker image using:

docker run -d -p 9001:9001 --name hyperbank-accounts hyperbank-accounts:1.0.0

but it gives me an error:

2024-01-21 15:10:59 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
2024-01-21 15:10:59 org.springframework.cloud.config.client.ConfigClientFailFastException: Could not locate PropertySource and the resource is not optional, failing
2024-01-21 15:10:59 Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8888/config/hyperbank-accounts/default": Connection refused

so the docker container hyperbank-accounts is not able to connect to hyperbank-config-provider container.

Instead, I'm able to reach the URL: http://localhost:8888/config/hyperbank-accounts/default

I have also tried to start hyperbank-accounts from eclipse, and is starting correctly, so it is able to connect to the docker container hyperbank-config-provider.

So I suppose there is an issue with docker containers. They are not able to talk with each other.

Which configuration I have missed?

0

There are 0 best solutions below