Docker Compose is an application definition and execution tool for multi-container docker applications. Using Docker Compose, you can connect all the isolated containers as a single service.
The containers are still segregated, but they can interact with one another. A YAML file makes it possible to configure the services of your application. Then, with one command, you create and start all services from your configuration.
With Docker Compose, you get the benefits of single host deployment, great security, and ease of set up & configuration which leads to really high productivity and efficiency.
What is Compose file?
- The file consists of a YAML file defining services, networks and volumes.
- The default path of a Compose file is ./docker-compose.yml
- It includes a service definition that configures each container launched for that service.
Docker Compose Benefits:
- Fast and simple configuration
- Secure internal communication
- Portability and CI/CD Support
- Efficient use of resources
Docker Compose Features:
- Host several remote environments on the same host.
- Supporting environment variables
- Preserving volume data
- Re-using existing containers
How to Use Docker Compose:
- Creating a Docker file for the app environment
- Defining services in docker compose.yml
- Starting the application.
Why you should use Docker Compose?
Docker Compose solves the problem by allowing you to use a YAML file to run multiple container applications at the same time. You may set the desired number of containers, their construction, and storage designs, and then, with a single command set, you can build, execute and configure all the containers. Docker Compose is ideal for development, testing and staging environments, as well as for seamless integration workflows.
Docker Compose Installation:
On Linux systems, first, install the Docker Engine on your OS
Use pip install docker-composer to install Docker Compose on your system
o root@ubuntu-14:~# sudo pip install docker-compose
Use docker-compose –version to verify your installation
o root@ubuntu-14:~# docker-compose --version
docker-compose version 1.27.0, build unknown