Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Does docker compose automatically put the containers in the same network?

I was recently trying to containerize an application that uses three services. When starting their containers separately with docker run, I also need to put them in the same network otherwise they can’t communicate. But I just wrote a docker-compose.yaml file to run them at the same time and they can communicate with each other even without specifying their network interface. Why is that?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

docker-compose create a stack with a default network.

From docker-compose documentation :
"By default Compose sets up a single network for your app. Each container for a service joins the default network and is both reachable by other containers on that network, and discoverable by the service’s name."

If you want to customize, you need to use network directive in your docker-compose.yml file.

Hope this help

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading