Docker Compose 


Docker compose allows you to construct and operate several containers at once, instead of running each image one by one to produce a running instance, 

Normally, you can launch an image with the docker run command, and if an application requires 10 or 20 or more containers to get it up and running, you can use the docker run command. Yes, we may start each container one by one with the docker run command in such instance.

However, with Docker compose, we can describe all of the information in a YAML file and up or down the entire container in one go. This is extremely helpful when managing huge container-based applications. This strategy is equally appropriate for a smaller project.

Docker-compose is included with the Docker engine. 

It works with Docker for Windows and Mac, but not with some Linux distributions. In that situation, docker-compose can be installed.

To install docker-compose, go to this page. https://docs.docker.com/compose/install/#install-compose-on-linux-systems

Check the version of docker


Check the version of docker-compose


Now, will create a config.yaml file. Which will have all the information about image , port, env variables, volumes etc.

Will have a basic .yaml file configuration, which have 2 image reference. One for mongo and another for mongo-express. These will pull nd run the image from Docker hub repository.


Now , once we have a .yaml file and all configuration set up. will run the docker compose up , referring to the file location of .yaml file.


We can see now the images and container are created and running in one go using docker compose up command.


To shut down all running container in one go. Can execute the docker-compose down command. And then verify the container status. It should be terminated and removed.