Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the module components of Docker

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "what are the module components of Docker". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what are the module components of Docker"?

The overall architecture of Docker

Docker is an architecture based on the Cmax S model, and the back end is a loosely coupled architecture, with each module performing its own functions. The following figure shows its overall architecture:

1. Users use Docker Client to establish communication with Docker Daemon and send requests to the latter.

2. As the main part of Docker architecture, Docker Daemon first provides the function of Docker Server so that it can accept the request of Docker Client.

3. Docker Engine performs a series of jobs within Docker, each of which exists in the form of a Job.

4. During the operation of Job, when a container image is needed, the image is downloaded from Docker Registry, and the downloaded image is stored as Graph through the image management driver Graphdriver.

5. When you need to create a network environment for Docker, create and configure the Docker container network environment through the network management driver Networkdriver.

6. When you need to restrict the Docker container to run resources or execute user instructions and other operations, it is done through Execdriver.

7. Libcontainer is an independent container management package. Networkdriver and Execdriver implement specific operations on containers through Libcontainer.

Analysis of each module component of Docker I. Docker Client "initiate request"

1. Docker Client is the client that establishes communication with Docker Daemon. The executable file used by the user is docker (a command line executable file), and the docker command uses the form of subsequent parameters to implement a complete request command (for example, docker images,docker is immutable, images is variable).

2. Docker Client can establish communication with Docker Daemon in three ways: tcp://host:port, unix://pathtosocket and fd://socketfd

3. After the Docker Client sends the container management request, the Docker Daemon accepts and processes the request. When the Docker Client receives the returned request and simply processes it, the complete life cycle of Docker Client ends. (a complete request: send the request → to process the request → returns the result), which is no different from the traditional Cmax S architecture request process.

2. Docker Daemon (background daemon)

Docker daemon architecture diagram:

Docker Server architecture diagram:

1. Docker Server is equivalent to the server of Cramp S architecture. The function is to accept and dispatch requests sent by the Docker Client. After accepting the request, Docker Server finds the corresponding Handler to execute the request through routing and distribution scheduling.

2. During the startup of Docker, a mux.Router is created through the package gorilla/mux to provide the routing function of the request. Gorilla/mux is a powerful URL router and dispatcher in Golang. A large number of routing items are added to the mux.Router, each of which is composed of HTTP request methods (PUT, POST, GET or DELETE), URL and Handler.

3. After the mux.Router is created, Docker takes the listening address and mux.Router of the Server as parameters to create a httpSrv=http.Server {}, and finally executes httpSrv.Serve () to serve the request.

4. During the service of Docker Server, Docker Server accepts the access request from Docker Client on listener and creates a new goroutine to serve the request. In goroutine, the request content is read and parsed at first, then the corresponding route entry is found and the corresponding Handler is called to process the request, and finally the Handler replies to the request after processing the request.

III. Docker Engine

1. Docker Engine is not only the running engine of Docker architecture, but also the core module of Docker running. It acts as a Docker Container repository and manipulates and manages these containers by executing Job.

2. In the design and implementation of Docker Engine data structure, there is a Handler object. This Handler object stores Handler processing access to many specific Job. Example: if there is an item in the Handler object of Docker Engine: {"create": daemon.ContainerCreate,}, it means that when the Job named "create" is running, it is executing the Handler of daemon.ContainerCreate.

Job

1. A Job can be considered as the most basic work execution unit within Docker Engine in Docker architecture. Everything Docker can do can be abstracted as a Job. For example: run a process inside the container, this is a Job; to create a new container, this is a Job. The running process of Docker Server is also a Job called ServeApi.

2. The designer of Job designed Job to be similar to the Unix process. For example, Job has a name, parameters, environment variables, standard input and output, error handling, return status, and so on.

4. Docker Registry (Mirror Registry)

1. Docker Registry is a repository (registry) that stores container images, which can be understood as cloud image repositories. Classified by Repository, docker pull defines a specific Image precisely according to [repository]: [tag].

2. During the operation of Docker, Docker Daemon communicates with Docker Registry and implements three functions: search image, download image and upload image. The corresponding Job names of these three functions are: "search", "pull" and "push".

3 Docker Registry can be divided into public warehouse (Docker Hub) and private warehouse.

5. Graph "Docker Internal Database"

Graph architecture diagram:

Repository

1. Custodian of downloaded images (including downloaded images and images built through Dockerfile).

Search the official account for the top architect to reply to the keyword "neat structure" to get a surprise gift package.

2. A Repository represents a repository of certain images (for example: Ubuntu). Images in the same Repository are distinguished by Tag (representing different tags or versions of the same type of images). A Registry contains multiple Repository, and a Repository contains multiple Image of the same type.

3. The storage types of images include Aufs, Devicemapper, Btrfs, Vfs and so on. Version 7.x of the CentOS system uses the storage type of Devicemapper.

4. At the same time, the specific information about each container image is stored in the local directory of Graph, including the metadata of the container image, the size information of the container image, and the specific rootfs represented by the container image.

GraphDB

1. The recorder of the relationship between container images has been downloaded.

2. GraphDB is a small database built on SQLite, which realizes the naming of nodes and the recording of the relationship between nodes.

VI. "Executive part" of Driver

Driver is the driver module in Docker architecture. Through Driver driver, Docker can customize the execution environment of Docker container. That is, Graph is responsible for the storage of the image and Driver is responsible for the execution of the container.

Graphdriver

Graphdriver architecture diagram:

1. Graphdriver is mainly used to manage container images, including storage and acquisition.

2. Storage: the images downloaded by docker pull are stored in the specified local directory (Graph) by Graphdriver.

3. Obtain: when docker run (create) uses an image to create a container, the Graphdriver goes to the local Graph to obtain the image.

Networkdriver

Networkdriver architecture diagram:

The purpose of Networkdriver is to complete the configuration of the Docker container network environment, including:

Create a bridge for the Docker environment when Docker starts.

Create a dedicated virtual Nic device for the Docker container when it is created.

Docker container assigns IP, port and port mapping to host, sets container firewall policy, etc.

Execdriver

Execdriver architecture diagram:

1. Execdriver, as the execution driver of the Docker container, is responsible for creating the container running namespace, the statistics and restrictions on the use of container resources, and the actual running of processes within the container.

2. Now Execdriver uses Native driver by default and does not depend on LXC.

7. Libcontainer "function library"

Libcontainer architecture diagram:

1. Libcontainer is a library designed and implemented in Go language in Docker architecture. The original design intention is that the library can directly access container-related API in the kernel without relying on any dependencies.

2. Docker can directly call Libcontainer to manipulate the container's Namespace, Cgroups, Apparmor, network devices and firewall rules.

3. Libcontainer provides a set of standard interfaces to meet the container management requirements of the upper layer. In other words, Libcontainer blocks the direct management of containers by the upper layer of Docker.

Docker Container "the final form of service delivery"

Docker Container architecture:

1. Docker Container (Docker container) is the final form of service delivery in Docker architecture.

2. Docker customizes the corresponding Docker container according to the user's needs and instructions:

Users specify container images to enable Docker containers to customize file systems such as rootfs.

The user causes the Docker container to use the specified computing resource by specifying a quota for the computing resource.

By configuring the network and its security policy, the Docker container has an independent and secure network environment.

The user causes the Docker container to perform the specified work by specifying the command to run.

At this point, I believe you have a deeper understanding of "what are the module components of Docker?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report