I have two services, spring boot docker and when I try communication with rest template I got java.net.ConnectException: Connection refused (Connection refused)
url is http://localhost:8081/api/v1/package/250Mbps
Service 1 docker-compose.yml:
product_catalogue_service:
image: openjdk:8-jdk-alpine
ports:
- "8081:8081"
volumes:
- .:/app
working_dir: /app
command: ./gradlew bootRun
restart: on-failure
Service 2 docker-compose.yml:
order_service:
image: openjdk:8-jdk-alpine
ports:
- "8083:8083"
volumes:
- .:/app
working_dir: /app
command: ./gradlew bootRun
restart: on-failure
Rest template URL, and it is working when I run project 2 from the IntelliJ: http://localhost:8081/api/v1/package/250Mbps
When I run docker ps, name of first service is: productcatalogueservice_product_catalogue_service_1
I tried to use that instead of localhost - unknown host exception.
I tried "product_catalogue_service_1" instead, also unknown host exception, and finally I tried "product_catalogue_service" also unknown host exception.
Any idea?