Docker(四)Docker Compose

Docker(四)Docker Compose

Introduction to Compose

  1. concept

The Compose project is an official open source project of Docker, responsible for the rapid orchestration of Docker container clusters. It is a docker application tool for defining and running multiple containers . Using compose, you can configure your own services through the YMAL file, and then with a single command, you can use the configuration file to create and run all services.

  1. composition

Docker-Compose divides the managed containers into three layers, namely project, service and container. All files (docker-compose.yml, extends files or environment variable files, etc.) in the Docker-Compose running directory form a project. If there is no special designation, the project name is the current directory name. A project can contain multiple services, and each service defines the image, parameters, and dependencies of the container running. A service can include multiple container instances.

  • Service:
    An application container can actually include several container instances running the same image. Each service has its own name, the image used, the data volume that it is mounted on, the network it belongs to, which other services it depends on, and so on. That is, with the container as the granularity, user needs, and tasks completed by Compose.
  • Project:
    A completed business unit composed of a set of associated application containers, defined in docker-compose.yml. That is, a configuration file of Compose can be parsed into a project. Compose analyzes the specified configuration file to obtain all the container management and deployment operations required by the configuration file.

The default project configuration file of Docker-Compose is docker-compose.yml. The configuration file can be customized through the environment variable COMPOSE_FILE or the -f parameter, which defines multiple dependent services and the container in which each service runs.

Using a Dockerfile template file allows users to easily define a separate application container. In work, we often encounter situations that require multiple containers to cooperate with each other to complete a task. For example: To deploy a Web project, in addition to the Web service container, it is often necessary to add a back-end database service container, or even a load balancing container.

Guess you like

Origin blog.csdn.net/weixin_42201180/article/details/108798548