1. Introduction

The Compose project is Docker’s official open source project, which is responsible for the rapid choreography of Docker container clusters. Functionally, it is very similar to Heat in OpenStack.

The code is currently available at github.com/docker/comp… On open source.

Compose is positioned as “Defining and running multi-container Docker applications”. Its predecessor is Fig, an open source project.

We know that using a Dockerfile template file makes it easy for users to define a separate application container. However, in daily work, it is common to encounter situations where multiple containers need to work together to complete a task. For example, to implement a Web project, in addition to the Web service container itself, there is often a database service container on the back end, and even a load balancing container.

Compose fits that need. It allows users to define a set of associated application containers as a Project through a single docker-comemage. yml template file (YAML format). Compose has two important concepts:

  • Service: A container for an application that can actually contain several instances of the container running the same image.
  • Project: A complete business unit consisting of a set of associated application containers, defined in the docker-comemess.yml file.

Compose’s default management object is a project, which provides easy lifecycle management through subcommands for a set of containers in a project. The Compose project is written in Python and its implementation calls the API provided by the Docker service to manage the container. Therefore, you can leverage Compose for orchestration management on any platform you operate on that supports the Docker API.

2. Install Docker Compose

Compose supports Linux, macOS, and Windows 10.

Installing on Linux is as simple as downloading the compiled binaries directly from the official GitHub Release.

First go to the official GitHub, find the Release page, and then find the latest Release, as shown below. The latest version is 1.27.3

Then run the following command to install. If the version is updated, just replace the following version:

The curl -l https://github.com/docker/compose/releases/download/1.27.3/docker-compose- ` ` uname - s - ` uname -m ` - o /usr/local/bin/docker-composeCopy the code

The installation process is as shown in the figure:

The resource access takes a long time.

If the installation is too slow, you can replace the docker-compose source with the following command: docker-compose

The curl -l https://get.daocloud.io/docker/compose/releases/download/1.27.3/docker-compose- ` ` uname - s - ` uname -m ` > /usr/local/bin/docker-composeCopy the code

Docker-compose is not an executable file.

To add the executable permission to its attributes, run the following command:

chmod +x /usr/local/bin/docker-compose
Copy the code

Docker-compose is installed successfully.

3. Check whether the installation is successful

docker-compose version
Copy the code

The output is as follows:

Docker-compose has been successfully installed.