There are 2 services with 2 docker-compose.yml files.
The services are connected via bridge network, so that they can communicate locally.
- service_1
docker-compose.yml
version: '3.7'
services:
django:
build:
context: .
ports:
- "6000:6000"
networks:
- shared-local-network
command: python manage.py runserver 0.0.0.0:6000
networks:
shared-local-network:
external: true
- service_2
docker-compose.yml
version: '3.7'
services:
django:
build:
context: .
ports:
- "8000:8000"
networks:
- shared-local-network
command: python manage.py runserver 0.0.0.0:8000
networks:
shared-local-network:
external: true
So those services are in different projects, but their service names are the same: django.
But when I am trying to request one service from another, for example send request to service_2 from service_1:
curl http://django:8000
It is not reachable.
netcat -vz django 8000 shows that it is not reachable as well.
I noticed that when sending request from service_1 to http://django:8000, it sends request to itself service_1, that's why it cannot find opened 8000 port, because service_1 has 6000 opened port.
Is it possible to resolve without renaming service to a unique one in docker-compose.yml?