Table of Contents
Compose
Machine
Swarm
Home Operation and Maintenance Docker What do the Three Musketeers in docker mean?

What do the Three Musketeers in docker mean?

Nov 25, 2021 pm 05:42 PM
compose docker swarm

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to exit the container by docker How to exit the container by docker Apr 15, 2025 pm 12:15 PM

Four ways to exit Docker container: Use Ctrl D in the container terminal Enter exit command in the container terminal Use docker stop <container_name> Command Use docker kill <container_name> command in the host terminal (force exit)

How to check the name of the docker container How to check the name of the docker container Apr 15, 2025 pm 12:21 PM

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

How to copy files in docker to outside How to copy files in docker to outside Apr 15, 2025 pm 12:12 PM

Methods for copying files to external hosts in Docker: Use the docker cp command: Execute docker cp [Options] <Container Path> <Host Path>. Using data volumes: Create a directory on the host, and use the -v parameter to mount the directory into the container when creating the container to achieve bidirectional file synchronization.

How to restart docker How to restart docker Apr 15, 2025 pm 12:06 PM

How to restart the Docker container: get the container ID (docker ps); stop the container (docker stop <container_id>); start the container (docker start <container_id>); verify that the restart is successful (docker ps). Other methods: Docker Compose (docker-compose restart) or Docker API (see Docker documentation).

How to start mysql by docker How to start mysql by docker Apr 15, 2025 pm 12:09 PM

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

How to update the image of docker How to update the image of docker Apr 15, 2025 pm 12:03 PM

The steps to update a Docker image are as follows: Pull the latest image tag New image Delete the old image for a specific tag (optional) Restart the container (if needed)

How to start containers by docker How to start containers by docker Apr 15, 2025 pm 12:27 PM

Docker container startup steps: Pull the container image: Run "docker pull [mirror name]". Create a container: Use "docker create [options] [mirror name] [commands and parameters]". Start the container: Execute "docker start [Container name or ID]". Check container status: Verify that the container is running with "docker ps".

How to create containers for docker How to create containers for docker Apr 15, 2025 pm 12:18 PM

Create a container in Docker: 1. Pull the image: docker pull [mirror name] 2. Create a container: docker run [Options] [mirror name] [Command] 3. Start the container: docker start [Container name]

See all articles