Managing Containers with Docker Compose
Compose is a tool for defining and running multi-container Docker applications.
Very Important concepts to begin with:
From Web development standpoint, Docker compose is definitely one of the more exciting pieces of doctor. It’s a great way to automatically manage the life cycle of your application in the development environment and get it up and running and stop it.
With the docker-compose we can run it through a doctor compose build process. And this build process can actually generate images that we can then use to create containers.
Creating Docker-Compose File
Docker-Compose uses YAML files as inputs for creation of Services. The docker-compose file contain following fields : version, services, networks, etc. The example of docker-compose file:
Once we have doctor-compose yaml file available, we can go into the terminal and run the doctor compose tool. That will automatically build or rebuild all of the different service images that we need that are all defined in our doctor-compose file.
$ docker-compose build
After creating the image, we can start up the container by just running up command
$ docker-compose up
And similiarly tear-down the created container with down command:
$ docker-compose down
For sample code project : Github Repo