Background technology
Docker is a senior container engine based on LXC of PaaS provider dotCloud exploitation, source code trustship is on Github, docker is based on go language and defers to Apache2.0 agreement and increases income, developer can be packed their application and rely on bag in a transplantable container, then it is published on any popular Linux machine, it is also possible to realize virtualization.
Docker container is to use sandbox mechanism completely, does not the most have any interface (app of similar iPhone).Almost without performance cost, can run in machine and data center easily.The most important thing is, they do not rely on any language, framework includes system.
Build standardized running environment based on docker and be different from existing technical scheme, and it can be avoided that the defect of prior art existence.Currently existing scheme is to run a set of puppet/chef, or an image file on a baseOS mostly, but both technical schemes are the most perfect, and the former needs baseOS to provide many preconditions and the latter can revise hardly;Additionally, the latter's file size is big, environmental management and Version Control itself are also problems.
Due to the docker virtualized feature of lightweight based on LXC, docker compares the most obvious feature of KVM etc and starts exactly soon, and resource occupation is little.This is primarily due to LXC and has the feature of lightweight, start fast, and docker can only load the part of each container change, such resource occupation is little, it is possible to can more quickly and take less resource compared with the virtualization scheme of KVM etc under stand-alone environment
The network schemer of docker includes host, container, none and bridge:
(1) host pattern: an independent NetworkNamespace will not be obtained the when of starting container, but share a NetworkNamespace with host, container will not fictionalize the network interface card of oneself, configures the IP etc. of oneself, but uses IP and the port of host;
(2) container pattern: this pattern specifies newly created container and the container existed share a NetworkNamespace rather than share with host;Newly created container will not create the network interface card of oneself, configure the IP of oneself, but share IP, port range etc. with a container specified, equally, two containers are except network facet, other as file system, process list etc. or isolation, the process of two containers can be communicated by lO network card equipment;
(3) none pattern: this pattern is different with the first two;In such a mode, Docker container has the NetworkNamespace of oneself, but, do not carry out any network configuration for Docker container, it is to say, this Docker container does not has the information such as network interface card, IP, route, us are needed oneself to add network interface card, configuration of IP etc. for Docker container;
(4) bridge pattern: bridge pattern is the network settings of Docker acquiescence, this pattern can be each container allocation NetworkNamespace, arrange IP etc., and is connected on a virtual bridge by the Docker container on a main frame.
When docker container starts, if being provided with the network schemer of distribution IP, such as bridge, in this mode, verify for avoiding IP address conflict to need, as it is shown in figure 1, IP, mask can obtained, the gateway stage locks, without IP address conflict, then docker container is obtained in that network of relation parameter and starts, and otherwise returns mistake;During locking, other container needs to wait in line, and causes the obstruction of container queue.
Summary of the invention
In order to solve above-mentioned technical problem, the invention provides a kind of method solving the docker container concurrent bottleneck of startup.The present invention, by revising the source code of docker, relies on and peripheral device communication, it is achieved the fixed direction allocation to docker network parameter, thus improves the concurrency performance that container starts so that container queue will not be blocked during a large amount of containers start.
The present invention realizes with following technical scheme, a kind of method solving the docker container concurrent bottleneck of startup, comprises the following steps:
S1. inquiry docker container Starting mode, if the network schemer of distribution IP, then carries out S2;If the network schemer of non-distribution IP, the most normally start;
S2. docker container identification is obtained;
S3. by the transmission of docker container identification to described docker Container Management platform;
The most described docker Container Management platform inquires about docker fixed direction allocation log according to described docker container identification, if Query Result is empty, then returns mistake, and described docker container can not start;If Query Result is not empty, then network parameter transmission corresponding with described docker container identification in docker fixed direction allocation log is started to described docker container, described docker container according to the network parameter obtained.
Preferably, described docker fixed direction allocation log is for recording the corresponding relation of the docker container network parameter corresponding with described docker container.
Preferably, described docker Container Management platform, for managing the record in described docker fixed direction allocation log, is modified including to the record in described docker fixed direction allocation log, increase and/or is deleted.
Preferably, described container identification is specially Container Name.
Preferably, described container identification is specially Container ID.
Preferably, described network parameter includes: the IP of container, the mask of container, the gateway of container.
Preferably, described docker Container Management platform is additionally operable to the corresponding relation managing described container with described container self attributes.
Preferably, described container self attributes includes: container grouping information and container running status.
Described docker Container Management platform manages the corresponding relation of described container and described container self attributes by Container Management log.
Described Container Management log includes the contents such as ID, Container ID, Container Name, hostname, command, slave node, group packet, running status, establishment time and associative operation, and described associative operation includes starting, stopping and restarting.
Described docker Container Management platform can also carry out ASSOCIATE STATISTICS to the content in described Container Management log, described statistical content includes but not limited to container sum statistics, container running status statistics, classified statistics, slave node statistics, IP resource pool statistics and available resources statistics, and described container running status includes running and stopping.
Preferably, said method is applied to docker container start and also need to following steps:
(1) source code of docker application container engine is downloaded;
(2) according to described method, described source code is modified;
(3) compile described source code, and generate the executable program for starting docker;
(4) docker Container Management platform is created;
(5) run described executable program and docker Container Management platform simultaneously.
The invention has the beneficial effects as follows:
The invention provides a kind of method solving the docker container concurrent bottleneck of startup.The present invention, by revising the source code of docker, relies on and peripheral device communication, it is achieved the fixed direction allocation to docker network parameter, thus improves the concurrency performance that container starts so that container queue will not be blocked during a large amount of containers start.
Detailed description of the invention
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing, the present invention is described in further detail.
In one embodiment, solve, as in figure 2 it is shown, a kind of, the method that docker container starts concurrent bottleneck, comprise the following steps:
S1. inquiry docker container Starting mode, if the network schemer of distribution IP, then carries out S2;If the network schemer of non-distribution IP, the most normally start;
S2. obtain docker Container Name, and connect docker Container Management platform;
S3. by the transmission of docker Container Name to described docker Container Management platform;
The most described docker Container Management platform inquires about docker fixed direction allocation log according to described docker Container Name, if Query Result is not empty, then carries out S5;If Query Result is empty, then returning mistake, described docker container can not start;
S5. by network parameter transmission corresponding with described docker Container Name in docker fixed direction allocation log to described docker container, described docker fixed direction allocation log is for recording the corresponding relation of the docker container network parameter corresponding with described docker container;
S6.docker container starts according to the network parameter obtained.
Described method is applied to docker container start and also need to following steps:
(1) source code of docker application container engine is downloaded;
(2) according to described method, described source code is modified;
(3) compile described source code, and generate the executable program for starting docker;
(4) docker Container Management platform is created;
(5) run described executable program and docker Container Management platform simultaneously.
Described docker Container Management platform, for managing the record in described docker fixed direction allocation log, is modified including to the record in described docker fixed direction allocation log, increase and/or is deleted;Described network parameter includes: the IP of container, the mask of container, the gateway of container.
If described docker container does not exists in fixed direction allocation log, then start and mistake occurs, and point out docker container described in manager not exist, described manager is by adding described docker container in described docker fixed direction allocation table, and after being described docker container configuration network parameter, update described docker fixed direction allocation log.After described docker orientation log is updated, described docker container can normally start.
Described docker fixed direction allocation log is as shown in table 1:
Table 1docker fixed direction allocation log
Described docker Container Management platform is additionally operable to the corresponding relation managing described container with described container self attributes;Described container self attributes includes: container grouping information and container running status.
Described docker Container Management platform manages the corresponding relation of described container and described container self attributes by Container Management log.
Described Container Management log includes the contents such as ID, Container ID, Container Name, hostname, command, slave node, group packet, running status, establishment time and associative operation, and described associative operation includes starting, stopping and restarting.
Described docker Container Management platform relies on mysql to research and develop.Mysql is a Relational DBMS, MySQLAB company of Sweden develop, belong to company under Oracle at present.The most popular Relational DBMS of mysql, in terms of WEB application, mysql is one of best RDBMS (RelationalDatabaseManagementSystem, relational database management system) application software.Mysql is a kind of associated data library management system, and linked database saves the data in different tables rather than all data is placed in a big warehouse, which adds speed and improve motility.The sql like language that mysql is used is the most frequently used standardized language for accessing data base.Mysql volume is little, speed is fast, the total cost of ownership is low, especially this feature of open source code so that mysql becomes the preference data storehouse building docker Container Management platform, and docker also is able to carry out communication with mysql data base.
Second embodiment, in the present embodiment, the Organization Chart of docker container start-up course is as shown in Figure 3, docker container start-up course needs to rely on 5 modules in needing, and is DockerDaemon, DockerClient respectively, Driver, Libcontainer and Container, wherein Driver also includes networkdriver, graphdriver and execdriver.
DockerDaemon is the finger daemon operating in backstage in Docker framework, substantially can be divided into DockerServer, Engine and Job tri-part.DockerDaemon may be considered the request being accepted DockerClient by DockerServer module, and processes request in Engine, then according to request type, is created that the Job specified and runs.
DockerDaemon Yu Driver interacts, carrying out practically process has following several possible: obtain mirror image to DockerRegistry, the localization being performed container mirror image by graphdriver is operated, performed the configuration of capacitor network environment by networkdriver, performed the execution work etc. of container internal operation by execdriver
Libcontainer is the bag in Docker for Container Management, and it realizes based on Go language, carries out container control by management namespaces, cgroups, capabilities and file system.Libcontainer creates container, and container is carried out life cycle management.As long as achieving a group interface of Libcontainer definition, Docker can run, and this just brings possibility for Docker realization is the most cross-platform.In general, Libcontainer itself is broadly divided into three bulk job contents, and one is establishment and the initialization of container, and two is container life cycle management, and three is management of process
Container object mainly contain container configuration, control, state such as shows at the function, is abstract to different platform container function.It is thread-safe inside each Container process.Because Container is likely destroyed by outside process, so whether container can be existed by each method detect.
This module architectures is the necessary framework starting docker, in the prior art, due to docker container allocation IP and mask, it is thus desirable to this process is locked, if the when of container batch operation in the cluster, it is easy for causing obstruction, and in this, obstruction has resulted in overstocking of the startup queue of container, thus have influence on efficiency and the stability that container starts;By revising the source code of docker in the present embodiment, rely on and peripheral device communication, and described docker fixed direction allocation log is achieved on external equipment, it is achieved thereby that the fixed direction allocation to docker network parameter, avoid the process locking and unlocking, this allow in the cluster batch operation when, it is possible to be rapidly performed by the startup of container, overcome the concurrent bottleneck problem in container start-up course.
It is being that a kind of of research and development under the framework of this example solves the method that docker container starts concurrent bottleneck, is comprising the following steps:
S1. inquiry docker container Starting mode, if the network schemer of distribution IP, then carries out S2;If the network schemer of non-distribution IP, the most normally start;
S2. obtain docker Container Name, and connect docker Container Management platform;
S3. by the transmission of docker Container Name to described docker Container Management platform;
The most described docker Container Management platform inquires about docker fixed direction allocation log according to described docker Container Name, if Query Result is not empty, then carries out S5;If Query Result is empty, then returning mistake, described docker container can not start;
S5. by network parameter transmission corresponding with described docker Container Name in docker fixed direction allocation log to described docker container, described docker fixed direction allocation log is for recording the corresponding relation of the docker container network parameter corresponding with described docker container;
S6.docker container starts according to the network parameter obtained.
Described method is applied to docker container start and also need to following steps:
(1) source code of docker application container engine is downloaded;
(2) according to described method, described source code is modified;
(3) compile described source code, and generate the executable program for starting docker;
(4) docker Container Management platform is created;
(5) run described executable program and docker Container Management platform simultaneously.
Described docker Container Management platform, for managing the record in described docker fixed direction allocation log, is modified including to the record in described docker fixed direction allocation log, increase and/or is deleted;Described network parameter includes: the IP of container, the mask of container, the gateway of container.
If described docker container does not exists in fixed direction allocation log, then start and mistake occurs, and point out docker container described in manager not exist, described manager is by adding described docker container in described docker fixed direction allocation table, and after being described docker container configuration network parameter, update described docker fixed direction allocation log.After described docker orientation log is re-updated, described docker container can normally start.
Described docker Container Management platform is additionally operable to the corresponding relation managing described container with described container self attributes;Described container self attributes includes: container grouping information and container running status.
Described docker Container Management platform manages the corresponding relation of described container and described container self attributes by Container Management log.
Described Container Management log includes the contents such as ID, Container ID, Container Name, hostname, command, slave node, group packet, running status, establishment time and associative operation, and described associative operation includes starting, stopping and restarting.
In addition, the present embodiment also including, described docker Container Management platform carries out ASSOCIATE STATISTICS to the content in described Container Management log, described statistical content includes container sum statistics, container running status statistics, classified statistics, slave node statistics, IP resource pool statistics and available resources statistics, and in the present embodiment, docker Container Management platform statistical table is as shown in table 2.
Table 2docker Container Management platform statistical table
Described docker Container Management platform includes docker fixed direction allocation log, Container Management log and docker Container Management platform statistical table, and described docker Container Management platform relies on mysql to research and develop, and above-mentioned three tables are carried out integrated management.
3rd embodiment, docker container start-up course needs to rely on 5 modules in needing, is DockerDaemon respectively, DockerClient, Driver, Libcontainer and Container, wherein Driver also includes networkdriver, graphdriver and execdriver.
Rely on above-mentioned 5 modules to solve the method that docker container starts concurrent bottleneck, comprise the following steps:
S1. inquiry docker container Starting mode, if the network schemer of distribution IP, then carries out S2;If the network schemer of non-distribution IP, the most normally start;
S2. obtain docker Container ID, and connect docker Container Management platform;
S3. by the transmission of docker Container ID to described docker Container Management platform;
The most described docker Container Management platform inquires about docker fixed direction allocation log according to described docker Container ID, if Query Result is not empty, then carries out S5;If Query Result is empty, then returning mistake, described docker container can not start;
S5. by network parameter transmission corresponding with described docker Container ID in docker fixed direction allocation log to described docker container, described docker fixed direction allocation log is for recording the corresponding relation of the docker container network parameter corresponding with described docker container;
S6.docker container starts according to the network parameter obtained;Described network parameter includes: the IP of container, the mask of container, the gateway of container.
Described method is applied to docker container start and also need to following steps:
(1) source code of docker application container engine is downloaded;
(2) according to described method, described source code is modified;
(3) compile described source code, and generate the executable program for starting docker;
(4) docker Container Management platform is created;
(5) run described executable program and docker Container Management platform simultaneously.
Described docker Container Management platform, for managing the record in described docker fixed direction allocation log, is modified including to the record in described docker fixed direction allocation log, increase and/or is deleted;Described network parameter includes: the IP of container, the mask of container, the gateway of container.
If described docker container does not exists in fixed direction allocation log, then start and mistake occurs, and point out docker container described in manager not exist, described manager is by adding described docker container in described docker fixed direction allocation table, and after being described docker container configuration network parameter, update described docker fixed direction allocation log.After described docker orientation log is re-updated, described docker container can normally start.
Described docker fixed direction allocation log is as shown in table 3:
Table 3docker fixed direction allocation log
Described docker Container Management platform is additionally operable to the corresponding relation managing described container with described container self attributes;Described container self attributes includes: container grouping information and container running status.
Described docker Container Management platform manages the corresponding relation of described container and described container self attributes by Container Management log.
Described Container Management log includes the contents such as ID, Container ID, Container Name, hostname, command, slave node, group packet, running status, establishment time and associative operation, and described associative operation includes starting, stopping and restarting.
Described docker Container Management platform uses docker Container Management platform statistical table that the content in described Container Management log carries out ASSOCIATE STATISTICS, and the content of described docker Container Management platform statistical table includes container sum statistics, container running status statistics, classified statistics, slave node statistics, IP resource pool statistics and available resources statistics.
The present embodiment also including, described docker Container Management platform is managed for IP resource pool, described docker Container Management platform uses IP resource pool management table to be managed described IP resource pool, described IP resource pool management table includes docker Container ID number corresponding to packet belonging to IP resource pool ID, IP resource pool title, IP resource pool, IP resource pool remarks, IP resource pool mask, IP resource pool mask annotation, IP resource pool gateway, IP resource pool gateway annotation, IP resource pool and the operation for described IP resource pool, and described operation includes revising and deletion.
Described docker Container Management platform includes docker fixed direction allocation log, Container Management log, IP resource pool management table and docker Container Management platform statistical table, described docker Container Management platform relies on mysql to research and develop, and above-mentioned four tables are carried out integrated management.
The above disclosed present pre-ferred embodiments that is only, certainly can not limit the interest field of the present invention, the equivalent variations therefore made according to the claims in the present invention with this, still belong to the scope that the present invention is contained.