Docker Composer : Docker Composer is basically used to run multiple containers as a single service. Compose provide a relationship between multiple containers. If we want to run multiple containers with a single service, what is the solution for this? Yes! Docker composer is the solution if we want to establish a relation between a single service and multiple containers. With the help of Docker Composer, you can use and you can start multiple containers as a single service.
Example : User can Start MySQL and Tomcat Container with one YML file without starting each separately.
To run both the service with on Docker Container, Admin or User will create a one YML file and Docker Composer will use this particular YML file to start both of the containers as a single service.
Docker Compose – Three-Step Process
- User or Admin need to define the application environment with a docker file so it can be executable, reproduced anywhere.
- Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
- Run command docker-compose up and Compose starts and runs your entire app.
Above are the three steps that will be performed when you want to execute the container with the help of docker-compose we need to follow these steps.
Steps to Install Docker Compose
To install Docker Compose, Docker should be installed first on your machine.
Step 1
To verify Docker, just check the Docker version with the following command
# sudo docker -v
Step 2
We need to download Dockers necessary, required files from GitHub. You can use the following command to download all files which are related to Docker Composer. As you can see we are going to download version 1.29.2 and this will be stored in a usr/local/bin/docker-compose directory.
# sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)"-o /usr/local/bin/docker-compose
Step 3
Once the download is complete, apply the executable permission to the binary files which we have downloaded in usr/local/bin/docker-compose folder
# sudo chmod +x /usr/local/bin/docker-compose
Step 4
Verify the Docker Compose Version.
# sudo docker-compose --version
As we can see, docker-compose version 1.29.2 with build number 5becea4c has been installed on my Ubuntu Machine. So, this is the way how you all can install docker composer in your machine.
Video Tutorial
Also Read : Install MySQL And WordPress With Docker Compose YML
So, in this tutorial we have covered how did we download and install Docker Compose using curl command on the Ubuntu machine. Docker Compose installed in usr/local/bin/docker-compose directory, we can change the directory but I will advise not to change because it’s a default directory for Docker Compose which is defined by Docker. In the next Docker post, we will learn about the Docker Compose YML file.