Docker basis (1) Principle articles

  • What is the Docker
  • Docker's constitution
  • A copy of the policy when Docker hierarchical and write
  • Docker difference with mainstream virtual machine
  • Relationship between the container and the mirror Docker
  • Mirroring change management

What is the Docker

Docker is an open source application container engine. The idea is to "Buildonce, Run anywhere, Configure once , Run anything", which proposed the Java "Write Once, Run Anywhere" has the same purpose.
Java and Docker in the face of problems transplantation of platform, using a similar solution. Language Java virtual machine associated with a particular shield information platform, so that only Java language compiler to generate object code (bytecode) that can run on the Java virtual machine can run without modification on multiple platforms .

Similarly, the use of container Docker engine platform dependent solve the problem, it will start a daemon on each Docker's host, daemon shield the information related to a specific platform, providing a unified interface to the upper layer application. Thus, Docker of applications can run on multiple platforms, will Docker for different platforms, parsing is performed to the corresponding drive, network storage drives, and the drive to perform.
Here that the main platform for different Linux distributions, because the realization of Docker's need to use the Linux cgroups, namespaces and other characteristics, it can only run on Linux environment, in order to use Docker on Windows and Mac, will have to use a virtual machine.

In addition, Docker also has its own ecosystem, downloaded from the official mirror mirror warehouse and can run on any operating system that has Docker engine, developers can also produce their own official repository mirror submitted for others to use. You can also set up private mirroring warehouse. This is similar to the Android or iOS system and application store relationship.

Finally, Docker also has version control, you can submit a new version of the image after making changes, you can quickly switch between multiple versions.

In summary, Docker container is an open source application engine, its application in the form of a mirror, by shielding Docker environmental differences, so that the application can be easily run in various environments, but also has Docker mirrored version control function.

Docker's constitution

Docker has its own sound ecosystem, in general, divided into warehouses and Docker Docker mirroring their own program in two parts.
Docker's own program which is divided into two parts Server and Client, using C / S architecture, written in Go.
Server-side Docker's also known Docker Daemon, in the form of table daemon running on the host later. Docker Client using flexible, may be transmitted in the form of instructions (e.g. Docker info, Docker start) bin in the machine commands, instructions may be transmitted at a distal end of the form RESTful API; Docker Server receives an end instruction and the instruction broken down into a series of tasks to perform.

When sending docker run command by Docker client to create and launch container, Docker Daemon first checks whether the local corresponding image, if not downloaded from the official repository, and then create and launch container based on the downloaded image, the final implementation of the results returned to the Docker Client.

A copy of the policy when Docker hierarchical and write

Docker and it will depend on the software environment (including operating systems and shared libraries, etc.), depending on configuration files packaged together into the official repository for others to download and use in the form of virtual machine images.
But the volume of the operating system software of the relative volume is too large, in order to run the software, each download supporting operating system is unrealistic. To solve this problem, Docker introduced the concept of layering. The application is divided into a plurality of layers of any such operating system is the first layer, dependent libraries and the second layer of third-party software, application software packages, and the third layer profile. If two applications have the same underlying, these layers can be shared. More in a large volume of the bottom layer, the greater may be shared.

But in a hierarchical manner will face the problem of shared layers of conflict, so Docker increase the priority attribute for the file level, upper and lower layers have the same files and configuration, the lower the upper cover. For example, application A needs to modify a configuration of the operating system, the application B does not need to be modified. Application A then give the highest priority to add a blank layer, if you need to modify the underlying file, put the files are copied to the blank layer to be modified to ensure that the underlying file without any change, this is called copy-on-write strategy .

应用A:              
====运行的应用====== 
======空白层======== 
=====配置文件======= 
=====依赖的库======= 
=====操作系统======= 
应用B:
====运行的应用======
=====配置文件=======
=====依赖的库=======
=====操作系统=======

Docker difference with mainstream virtual machine

KVM, Xen, VMWare, VirtualBox virtual machine and other mainstream generally more cumbersome, time is running in the virtual machine itself must consume a large amount of system resources (CPU, memory, etc.), but this type of virtual machine start-up time is relatively long, at every turn take a few minutes.
And to OpenVZ, VServer, LXC containers represented a virtual machine, virtualization technology is a core, and running in the same host Linux kernel, without an instruction level simulation, the performance of consumption is very small, a very lightweight Virtual of the container, the container virtual system resource consumption and almost a normal process. Docker is to use LXC (later launched libcontainer) allows virtual machine becomes lighter.

Relationship between the container and the mirror Docker

Then the container is mirroring what to do with it, from the foregoing description that: mirroring defined by their layered, can be understood LXC / libcontainer file storage format. Docker applications are published in this format to Docker warehouse, for everyone to use. The container refers to: the application downloaded from a mirror Docker warehouse to the local machine, a mirror-image as a template to start the application in a container class virtual machine, the virtual machine is called a container.
From another perspective, the mirror and the container can be seen as two different states of a Docker application. When the mirror state, only the necessary files required to run an application, the package contents, etc., but also in the rest state the application; the state of the container, the application to be run together to provide services, it is possible to modify the file, such as the output log, the dynamic update a configuration and so on, then there is need for copy-on-write blank layer.

Mirroring change management

The use of tiered storage mirroring feature, Docker can also be flexible change management.
For example, a mirror image of its V1.0 Docker three versions, and now it should be modified as follows: A Review of the first layer is located in the file; delete file B is located in the second layer; add a new file C.
In this case a fourth layer will increase, making changes in this layer: the first layer, the fourth layer to copy the file A, modify the contents of file A; in the fourth layer, the file name is set to not B presence; in the fourth layer, create a new file C.

v1.0:                      
                      
=====第三层 50M=====  
=====第二层 500M====  
=====第一层 1G======  
v1.1:                        
===第四层 修改 1M===
=====第三层 50M=====
=====第二层 500M====
=====第一层 1G======

This amendment is complete, at the time of publication of this new edition to the warehouse, because the first three already stored in the warehouse, you only need to upload a small volume of the fourth layer on it. When you use this image to other machines you want to upgrade version, also simply download from the warehouse fourth floor.
This shows that the importance of stratification characteristics for Docker, the use of hierarchical nature, Docker can do incremental mirroring changes, so that the image upload download Docker become very lightweight (in addition to the first operation).

Shenkaoziliao
Lee Jin-bang Liu Ye Yin Chen Chun-day Sri Lanka a "step by step learn Docker"

Guess you like

Origin www.cnblogs.com/zhixin9001/p/12357919.html