Docker compose

Docker compose

Creating config file for each container is teadious task if we have to run multiple containers on multiple machines, we create one docker compose (yaml) file with specification/variables of all containers. Docker compose helps creating common netowrk.

eg- it is helpful when for an app we are using multiple containers, we can run all containers at once using docker compose.

cmd to run docker compose yaml file- "docker-compose -f mongo.yaml up"

cmd to stop all containers in yaml file- "docker-compose -f mongo.yaml down" (stops all container & the default created network)

Docker compose helps creating common network by default to run all the containers mentioned in yaml file so we don't have to create newtwork manually.

Manual process is: we create a network, then we assign same network while creating our different containers, so our containers can interact by just using container name without need of local host, port.