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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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 use docker desktop How to use docker desktop Apr 15, 2025 am 11:45 AM

How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

How to create a mirror in docker How to create a mirror in docker Apr 15, 2025 am 11:27 AM

Steps to create a Docker image: Write a Dockerfile that contains the build instructions. Build the image in the terminal, using the docker build command. Tag the image and assign names and tags using the docker tag command.

How to change the docker image source in China How to change the docker image source in China Apr 15, 2025 am 11:30 AM

You can switch to the domestic mirror source. The steps are as follows: 1. Edit the configuration file /etc/docker/daemon.json and add the mirror source address; 2. After saving and exiting, restart the Docker service sudo systemctl restart docker to improve the image download speed and stability.

How to read the docker version How to read the docker version Apr 15, 2025 am 11:51 AM

To get the Docker version, you can perform the following steps: Run the Docker command "docker --version" to view the client and server versions. For Mac or Windows, you can also view version information through the Version tab of the Docker Desktop GUI or the About Docker Desktop menu.

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 view logs from docker How to view logs from docker Apr 15, 2025 pm 12:24 PM

The methods to view Docker logs include: using the docker logs command, for example: docker logs CONTAINER_NAME Use the docker exec command to run /bin/sh and view the log file, for example: docker exec -it CONTAINER_NAME /bin/sh ; cat /var/log/CONTAINER_NAME.log Use the docker-compose logs command of Docker Compose, for example: docker-compose -f docker-com

How to build a private repository by docker How to build a private repository by docker Apr 15, 2025 am 11:06 AM

You can build Docker private repositories to securely store and manage container images, providing strict control and security. The steps include: creating a repository, granting access, deploying a repository, pushing an image, and pulling an image. Advantages include security, version control, reduced network traffic and customization.

How to run the docker command How to run the docker command Apr 15, 2025 am 11:24 AM

How to run Docker commands? Install Docker and start the daemon. Common Docker commands: docker images: display image docker ps: display container docker run: run container docker stop: stop container docker rm: delete container interact with container using Docker command: docker exec: execute command docker attach: attach console docker logs: display log docker commit: commit change to mirror stop Docker daemon: sudo systemctl stop doc

See all articles