Open smilinazzo opened 1 month ago
@smilinazzo I’ve used port binding to the host to avoid ports conflicts as some containers are using same port 9997 and the different/separate containers need to communicate with each other over the host network.
Each port 9997
is internal to the container that is running each service. So, there should be no conflicts.
Are we sure they are communicating over the host
network?
With your compose file, you have a number of services: target_1
, target_2
, agent
, and splitter
. When you start those services with docker-compose up
, what are the steps that Docker-Compose takes?
okay noted. Sorry for my misunderstanding here. They are not communicating over the host network but the docker network, and there won't be any port conflicts. Port binding can be used to access the container from the host machine such as localhost:
Firstly, docker-compose will read the compose file and check all the configurations, services, networks, volumes etc.. then it will check if any service depends on each other and start the services accordingly. It will then build or pull images and create a network. Then it will creates the volumes and finally starts the containers. Finally, it will add the logs and monitor the lifecycle of the services.
https://github.com/Ikshi/assignment/blob/cdde9f40d9217ba45bb7440288e2cf3fa4e71ae3/docker-compose.yml#L9
Interesting that you are publishing port to the host. Can you explain your reasoning for this?