What do the Three Musketeers in docker mean?

青灯夜游
Release: 2021-11-25 19:40:21
Original
6046 people have browsed it

The three swordsmen in docker refer to swarm, compose and machine. Compose is a tool used to define and run one or more containers and applications; Machine is a command line tool that simplifies Docker installation; Swarm is a tool provided by the community that natively supports Docker clusters.

What do the Three Musketeers in docker mean?

The operating environment of this tutorial: linux5.9.8 system, docker-1.13.1 version, Dell G3 computer.

The three swordsmen in docker containers are swarm, compose and machine.

Compose

1. Overview

In an actual production environment, an application is often composed of many services , and the best practice of Docker is that a container only runs one process, so running multiple microservices requires running multiple containers. Multiple containers working together require an effective tool to manage them and define how these containers relate to each other. compose came into being.

compose is a tool used to define and run one or more containers (usually multiple) to run and apply. Using compose can simplify the construction of container images and the running of containers.

compose uses YAML files to define relationships between multiple containers. A docker-compose up can run the complete application. Essentially, compose parses the YAML file into the parameters of the docker command, and then calls the corresponding docker command line interface to manage the application in a containerized manner. It starts containers sequentially by resolving dependencies between containers. Dependencies between containers are specified by the links tag in the YAML file.

2. Introduction to compose configuration

Compose is an encapsulation of docker commands, and docker-compose.yml is used by default The file specifies the parameters in each command.
A simple example:

web:
  build: .
  ports:
  - 8080:80
  volumes:
  - . : /code
  links:
  - redis
redis:
  image: redis
Copy after login

This YAML file defines two services: Web and Redis. The name of the service is customized by the user. The image that provides the Web service is built from the Dockerfile; the Web service listens to port 80 and maps it to the host's port 8080; the current directory of the host is mounted to the /code directory in the container; the Web server accesses the backend Redis database by linking to the Redis container. . The Redis database service is provided by running the Redis image.

In the docker-compose.yml file, each defined service contains at least one of build or image, and other commands are optional. The build command specifies the directory containing the Dockerfile, which can be a relative directory or an absolute directory.

The "ports" tag in the docker-compose.yml file corresponds to the "-p" option of docker run; the "volumes" tag corresponds to the "-v" option of docker run; the "links" tag corresponds to docker run The "--links" option.

In addition, image is used to specify the image of the service.

Finally, execute the docker-compose up command in the directory where docker-compose.yml is located, and the Web and Redis services will run successfully.

Machine

1. Overview

Docker Machine is a command line tool that simplifies Docker installation. Docker can be installed on the corresponding platform through a simple command line, providing users with flexible functions so that they can run Docker containers on any host. Simply put, a Docker Machine is a combination of a Docker host and a configured Docker client.

Technically speaking, Machine is a framework and is relatively open. For any platform that provides virtual machine services, as long as a driver for the platform is developed under this framework, Docker Machine can be integrated into the platform and perform actions such as creation, deletion, startup, and stop on the platform.

The architecture of Docker Machine is shown in the figure

What do the Three Musketeers in docker mean?

2. Basic concepts and processes of Machine

Docker Machine first creates a virtual machine and a Docker host on it, and then uses the Docker client to communicate with the Docker host to create an image on the Docker host and start the container.

When using Docker Machine to create a virtual machine, you need to develop the corresponding driver. Currently, the drivers that support this machine include VirtualBox driver, VMware driver and Hyper-V driver under Windows. In addition, Machine also supports the creation of cloud hosts. As long as a driver that conforms to the framework specifications is developed, Docker Machine can support the corresponding platform.

The IP address of the Docker host created by Machine is the IP address of the virtual machine created.
The running process of using Docker Machine and VirtualBox driver to create a local virtual machine and build Docker host is as follows:

  • Execute the docker-machine create --driver virtualbox dev command. This command first creates a CA certificate for communication between Docker client and Docker host. Next, create a VirtualBox virtual machine, configure TLS parameters for communication and configure the network, and finally deploy the Docker operating environment, that is, Docker host.

  • Run the eval "$(docker-machine env dev)" command in the Docker client to configure the environment variables used for Docker host communication.

  • Use docker related commands to create or start the corresponding container.

Swarm

1. Overview

Swarm is the Docker community Provides tools that natively support Docker clusters. It can convert a system composed of multiple Docker hosts into a single virtual Docker host. Swarm provides two APIs to the outside world. One is the standard Docker API, such as Dokku, Compose, Krane, Flynn, Deis, Jenkins, etc.; the other is Swarm's cluster management API, which is used for cluster management.

The Swarm tool itself is not very mature and is not recommended for use in production environments.
And Google’s open source Kubernetes is currently the most popular orchestration and deployment tool in the container ecosystem.
The architecture of Kubernetes is based on a Master server with multiple Minion nodes. I haven’t come into contact with K8s yet. I will summarize it here after I learn more about it.

K8s Architecture Block Diagram

What do the Three Musketeers in docker mean?

Component explanation:

  • Master: Master server, running the management process of kebernetes , including API services, backup controllers and schedulers, etc.
  • Minion: The host of Kubelet service and Docker engine. Minion accepts instructions from Master
  • Kubelet: Kubernetes node-level manager, running on Minion
  • Pod: Multiple A collection of containers, and these containers run on the same Minion. Pod is the smallest management unit of K8s
  • Replication Controller: manages the life cycle of Pod
  • Service: defines the services and ports that allow the container to be exposed, as well as external agents for communication and interaction
  • Kubecfg: Command line interface, interacts with the Master, and requests the deployment and management of application services

Recommended learning: "docker video tutorial"

The above is the detailed content of What do the Three Musketeers in docker mean?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!