How it works now:
Microservice X makes REST API request to Microservice Y with static ip
http://{ip-address}:{port}/doSomething
The problem:
The problem is that I can no long guarantee that static ip. I wan't to solve this by using the docker hostname instead:
http://hostname:{port}/doSomething
I tried achieving this by creating a used defined network in docker-compose:
#part of docker-compose file
streamapp:
hostname: twitterstreamapp
image: twitterstreamapp
container_name: twitterstreamapp
restart: always
ports:
- '8090:8080'
build:
context: ./TwitterStream
dockerfile: Dockerfile
storeapp:
hostname: twitterstoreapp
image: twitterstoreapp
container_name: twitterstoreapp
restart: always
ports:
- '8095:8080'
build:
context: ./TwitterStore
dockerfile: Dockerfile
depends_on:
- 'mysql-db'
networks:
- backend
volumes:
MyDataVolume:
networks:
backend:
driver: bridge
I can ping from Container X to Container Y. But not Curl for example. How can I fix this, or is this not the best way to achieve what I want.