0

I have 2 dockerized spring boot microservices:

Address service is called by person service using webclient as follows:

 public Optional<Address> findByAddressNo(int addressNo) {

        return Optional.ofNullable(
                WebClient.create()
                        .get()
                        .uri("http://address-api:8080/address/" + addressNo)
                        .retrieve()
                        .bodyToMono(Address.class)
                        .block());
    }

The docker compose file for the address service contains the following:

services:
  address-api:
    build: .
    restart: always
    ports:
      - "8083:8080"
    depends_on:
      sale:
        condition: service_healthy
    hostname: address-api

and app.props is:

spring.data.mongodb.host=address
spring.data.mongodb.port=27017
spring.data.mongodb.database=address

I can hit my person service endpoint ok, but when it makes the call to the address service I get the following:

{
    "message": "Internal Server Error: Failed to resolve 'address-api' [A(1)]"
}

I am starting both micro services separately via docker-compose, i.e. running docker compose up in each project.

What is the issue here, I am assuming I have configured something incorrectly.

java12399900
  • 1,485
  • 7
  • 26
  • 56
  • Is the person service in the same `docker-compose.yml` file? Are there any `networks:` settings in the file? – David Maze May 30 '23 at 22:09
  • @DavidMaze Hi, no they are in 2 separate docker compose files. there are no network settings enabled, should I move them to the same docker compose file and add network settings? – java12399900 May 31 '23 at 07:30
  • The simplest thing is to move them to the same Compose file, but not add any `networks:` settings. [Communication between multiple docker-compose projects](https://stackoverflow.com/questions/38088279/communication-between-multiple-docker-compose-projects) describes what you would need to do if you wanted to keep them separate. (In that question, note that Compose defaults to `networks: [default]` for all containers, which may affect your choice of network name.) – David Maze May 31 '23 at 10:18

0 Answers0