CN106227579B - Docker container construction method and Docker management console - Google Patents

Docker container construction method and Docker management console Download PDF

Info

Publication number
CN106227579B
CN106227579B CN201610546234.5A CN201610546234A CN106227579B CN 106227579 B CN106227579 B CN 106227579B CN 201610546234 A CN201610546234 A CN 201610546234A CN 106227579 B CN106227579 B CN 106227579B
Authority
CN
China
Prior art keywords
layer
mirror image
instruction
image
mirror
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610546234.5A
Other languages
Chinese (zh)
Other versions
CN106227579A (en
Inventor
李傲
高峰
熊华忠
刘祥涛
孙淏添
赵彦晖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Cubic Information Technology Co Ltd Is Moistened In Shenzhen
Original Assignee
Cubic Information Technology Co Ltd Is Moistened In Shenzhen
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Cubic Information Technology Co Ltd Is Moistened In Shenzhen filed Critical Cubic Information Technology Co Ltd Is Moistened In Shenzhen
Priority to CN201610546234.5A priority Critical patent/CN106227579B/en
Publication of CN106227579A publication Critical patent/CN106227579A/en
Application granted granted Critical
Publication of CN106227579B publication Critical patent/CN106227579B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses Docker mirror image construction methods and a Docker management console, which are used for adding a layer-combining instruction in a mirror image construction script, so that in the Docker mirror image construction process, merging of a plurality of mirror image layers can be realized according to the layer-combining instruction, the number of Docker mirror image levels and the data volume of mirror image files are reduced, the working efficiency is improved, and storage resources are saved.

Description

Docker container construction method and Docker management console
Technical Field
The invention relates to the technical field of computers, in particular to Docker container construction methods and a Docker management console.
Background
In a computer, Virtualization (Virtualization) is resource management technologies, which present various physical resources of the computer, such as servers, networks, memories, and storages after abstraction and conversion, and break the barrier of un-cuttable physical structures, so that users can apply these resources in a better way than the original configuration.
Docker is virtualization technologies, built on top of lightweight virtualization means LXC (LinuxContainer), and is lightweight virtualization solutions based on process containers (process containers). Docker is a platform which encapsulates the whole software runtime environment and is designed for developers and system administrators and is used by users to build, publish and run distributed applications.Docker has the most obvious characteristics of fast start and small resource occupation compared with other virtualization technologies, so that Docker is cross-platform, portable, simple and easy-to-use container solutions for building isolated standardized running environments, lightweight PaaS, building automated testing and persistent integration environments, and horizontally expandable applications (especially web applications which need to be fast start and stop to cope with peaks).
Aufs is combined file system (Union File System, Union FS), storage engines supported by Docker earliest, which simply supports different directories to be mounted under the same virtual file systems and combines the contents under each source directory under a target directory to realize the concept of layers (layer). Aufs sets multiple directories mounted under the same virtual file system to different authorities respectively, when mounting directories, the directory is strictly according to the increment relation between directories, the directory operated by increment is prior to the directory operated on the basis of the directory mounted by increment, and after all the directories are mounted, read-write directories are continuously mounted, so that hierarchical structure is formed.
The Docker file system is shown in fig. 1 and includes a boot file system (bootfs) and a root file system (rootfs), the bootfs includes a boot loader (bootloader) and a kernel (kernel), a user never modifies the boot fs, and actually, after the boot loading is completed, the whole kernel is in a memory, and the boot fs is unloaded to release the memory associated with the initial RAM disk. Rootfs has a standard structure of Unix-like systems, including/dev,/proc,/bin,/etc,/lib,/usr,/tmp, and all configuration files, binary files and library files (like bash, ls, etc.) that users need to run various applications.
When a traditional Linux loads a bootfs, a rootfs is set as read-only (read-only), then the rootfs is changed from read-only to read-write (read-write) after a system self-check is finished, and then writing and reading operations can be performed on the rootfs, but the mirror image of a Docker is not so, and the rootfs is not changed from read-only to read-write after the bootfs self-check is finished, but or more read-only rootfs are loaded on the previous read-only rootfs layer by using an union mount ( mount mechanisms of a union fs), after the multilayer rootfs is loaded, the rootfs still looks like file systems, the rootfs mirror images of union mounts are called Docker in the Docker system, but the rootfs image of the union mount is still called Docker (image) but each layers of the rootfs, the rootfs image of the rootfs is also called Docker, the Docker is not used for creating a read-only image of a Docker, and the rooter is used as a virtual container, wherein the rooter is created by using a virtual container, the rooter is called 3914, and the rooter, the rooter is used for instantiating a virtual container, the virtual container, wherein the rooter is shown in the following steps:
Figure BDA0001047339180000021
it can be seen that there are 4 serial number (uuid) mirror layers (layer) in the image of Ubuntu and inherited in tree structures, where the n +1 th layer inherits the nth layer and has its own content on this basis, the intuitive expression is that the n +1 th layer occupies an increased disk space, for example, 188MB for the image layer with uuid 09694f91574e, and the image layer with uuid 1b19f5a8e3aa is a parent image of 09694f91574e, 187.8 MB. for the disk space, and different images may have the same parent image, for example 955 for the image layers with uuid 09694f91574e, 27ff 53489 and c917d6497f55, where the parent images of the images are all images in the image layer of 1b19f5a8e3 aa.
However, the existing Docker image construction method in the existing Docker container platform system deployed in a clustered manner has the following disadvantages:
1. the Docker image level limitation cannot exceed 127 levels, so the image level number of compiling a new image version is limited, if the image level exceeding 127 levels needs to be merged, because the number of image levels is large, the operation executed by each level is complex, so that many changed files are generated, and when the image levels are merged, time is consumed for comparing each level with the file of the upper level, and the efficiency is very low;
2. when a Docker mirror image is updated, the level information of the mirror image needs to be compared each time, and whether each mirror image layer in a mirror image warehouse exists in a container host computer or not, the more mirror image levels, the more time is consumed by corresponding comparison;
3. each mirror image layer needs to occupy certain disk space, and the mirror image layers are inherited by a tree structure, so that files of each mirror image layer are not necessary, and the waste of storage resources of a mirror image warehouse server and a container host is caused;
the three disadvantages cause low working efficiency of the clustered deployed Docker container platform system and waste of storage resources.
Disclosure of Invention
The invention provides Docker mirror image construction methods and a Docker management console, which are used for adding a layer-combining instruction in a mirror image construction script, so that in the Docker mirror image construction process, a plurality of mirror image layers can be combined according to the layer-combining instruction, the number of Docker mirror image layers and the data volume of mirror image files are reduced, the working efficiency of a Docker container platform system is improved, and storage resources are saved.
The invention provides a Docker mirror image construction method in the aspect, which comprises the following steps:
acquiring a relevant application file and a mirror image construction script of an application, wherein the mirror image construction script comprises a combined layer instruction, and the combined layer instruction comprises a target mirror image layer identifier;
compiling the mirror image of the related application file according to the mirror image construction script to obtain a Docker mirror image layer;
if the current instruction is the combined layer instruction, acquiring a mirror image file of a current mirror image layer in the Docker mirror image layer, and acquiring a mirror image file of a target mirror image layer corresponding to the target mirror image layer identifier, wherein the current mirror image layer is positioned above the target mirror image layer;
obtaining a difference file according to the image file of the current image layer and the image file of the target image layer, and constructing a combined image layer according to the difference file;
submitting the combined layer mirror layer to a mirror repository.
With reference to the aspect of the present invention, in an implementation manner of the aspect of the aspect of the present invention, the acquiring a related application file and an image construction script of an application includes:
acquiring a relevant application file of an application;
determining the number of historical versions of the application according to the related application files, wherein the number of the historical versions is at least two;
generating mirror image compiling instructions according to the historical version number, wherein the mirror image compiling instructions are the same as the historical version number;
determining a target mirror image layer identifier and a combined layer instruction position according to the historical version number and a preset combined layer rule;
generating a combined layer instruction according to the target mirror layer identification, inserting the combined layer instruction between the mirror compiling instructions according to the combined layer instruction position, and generating a mirror constructing script.
With reference to the implementation manner of the aspect of the present invention and the second implementation manner of the aspect of the present invention, the compiling the image of the relevant application file according to the image construction script to obtain a Docker image layer includes:
acquiring a mirror image compiling instruction before the combined layer instruction in the mirror image construction script;
and executing the mirror image compiling instruction, and carrying out mirror image compiling on the related application files to obtain a Docker mirror image layer, wherein the Docker mirror image layer comprises a target mirror image layer.
With reference to the second embodiment of the aspect of the present invention, in a third embodiment of the aspect of the present invention, the acquiring an image file of a current image layer in the Docker image layer and an image file of a target image layer corresponding to the target image layer identifier includes:
if the current instruction is the combined layer instruction, acquiring a mirror image file of a current mirror image layer in the Docker mirror image layer;
and determining a target mirror image layer from the Docker mirror image layer according to the target mirror image layer identification in the combined layer instruction, and reading out the mirror image file of the target mirror image layer from the target mirror image layer.
With reference to the third embodiment of the aspect of the present invention, in the fourth embodiment of the aspect of the present invention, after submitting the laminated mirror image layer to a mirror repository, the method further includes:
and sending an updating instruction to the container host corresponding to the application, so that the container host downloads the image file in the synthetic image layer from the image warehouse according to the updating instruction.
A second aspect of the present invention provides kinds of Docker management consoles, each of which is included in a Docker container platform system further including a mirror warehouse server, the Docker management console including:
the system comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring relevant application files and mirror image construction scripts of applications, the mirror image construction scripts comprise a combined layer instruction, and the combined layer instruction comprises a target mirror image layer identifier;
the mirror image compiling module is used for carrying out mirror image compiling on the related application files according to the mirror image construction script to obtain a Docker mirror image layer;
the image file acquisition module is used for acquiring an image file of a current image layer in the Docker image layer and acquiring an image file of a target image layer corresponding to the target image layer identification when the current instruction is the combined layer instruction, wherein the current image layer is positioned above the target image layer;
the layer combining module is also used for obtaining a difference file according to the image file of the current image layer and the image file of the target image layer, and constructing a layer combining image layer according to the difference file;
and the mirror image submitting module is used for submitting the combined mirror image layer to a mirror image warehouse in the mirror image warehouse server.
With reference to the second aspect of the present invention, in an th implementation manner of the second aspect of the present invention, the obtaining module includes a obtaining unit and an instruction generating unit;
the acquisition unit is used for acquiring the relevant application files of the application;
the instruction generating unit is used for determining the number of the historical versions of the application according to the related application files, and the number of the historical versions is at least two;
the instruction generating unit is further configured to generate mirror image compiling instructions according to the historical version number, and the number of the mirror image compiling instructions is the same as the historical version number;
the instruction generating unit is further used for determining a target mirror image layer identifier and a combined layer instruction position according to the historical version number and a preset combined layer rule;
the instruction generating unit is further configured to generate a combined layer instruction according to the target mirror layer identifier, and insert the combined layer instruction between the mirror compiling instructions according to the combined layer instruction position to generate a mirror constructing script.
With reference to implementation manner of the second aspect of the present invention, in the second implementation manner of the second aspect of the present invention, the mirror compiling module includes an instruction obtaining unit and an instruction executing unit;
the instruction obtaining unit is used for obtaining a mirror image compiling instruction before the combined layer instruction in the mirror image construction script;
the instruction execution unit is configured to execute the mirror image compiling instruction, perform mirror image compiling on the relevant application file, and obtain a Docker mirror image layer, where the Docker mirror image layer includes a target mirror image layer.
In combination with the second embodiment of the second aspect of the present invention, in the third embodiment of the second aspect of the present invention,
the image file obtaining module is specifically configured to obtain an image file of a current image layer in the Docker image layer when the current instruction is the combined-layer instruction;
the image file obtaining module is further configured to determine a target image layer from the Docker image layer according to the target image layer identifier in the combined layer instruction, and read an image file of the target image layer from the target image layer.
With reference to the third embodiment of the second aspect of the present invention, in a fourth embodiment of the second aspect of the present invention, the Docker management console further includes: a sending module;
the sending module is configured to send an update instruction to the container host corresponding to the application, so that the container host downloads the image file in the synthesized image layer from the image warehouse according to the update instruction.
In summary, the embodiments of the present invention have the following advantages:
the method comprises the steps of obtaining relevant application files of applications and a mirror image building script, wherein the mirror image building script comprises a combined layer instruction, the combined layer instruction comprises a target mirror image layer identification, carrying out mirror image compilation on the relevant application files according to the mirror image building script to obtain a Docker mirror image layer, obtaining a mirror image file of a current mirror image layer in the Docker mirror image layer and obtaining a mirror image file of a target mirror image layer corresponding to the target mirror image layer identification when the current instruction is the combined layer instruction, wherein the current mirror image layer is located above the target mirror image layer, obtaining a difference file according to the mirror image file of the current mirror image layer and the mirror image file of the target mirror image layer, constructing the combined layer mirror image layer according to the difference file, submitting the combined layer mirror image layer to a mirror image warehouse, combining all mirror image layers between the current mirror image layer and the target mirror image layer when the combined layer instruction is executed, wherein the combined layer image layer comprises combined layer mirror image layer difference files, and compared with the prior art, the number of the Docker mirror image layers and the data volume of the mirror image files.
Drawings
In order to more clearly illustrate the technical solution of the embodiments of the present invention, the drawings used in the description of the embodiments and the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without creative efforts.
FIG. 1 is a schematic diagram of a conventional Docker file system;
FIG. 2 is a schematic structural diagram of a conventional Docker mirror;
FIG. 3 is a schematic structural view of a Docker vessel platform system of the present invention;
FIG. 4 is a schematic structural diagram of a Docker mirror image of the present invention;
FIG. 5 is a schematic flow chart of steps of a Docker mirror image construction method according to an embodiment of the present invention;
FIG. 6 is a diagram illustrating configurations of a Docker management console in an embodiment of the present invention;
fig. 7 is another schematic structural diagrams of the Docker management console in the embodiment of the present invention.
Detailed Description
The invention provides Docker mirror image construction methods and a Docker management console, which are used for adding a layer-combining instruction in a mirror image construction script, so that in the Docker mirror image construction process, a plurality of mirror image layers can be combined according to the layer-combining instruction, the number of Docker mirror image layers and the data volume of mirror image files are reduced, the working efficiency is improved, and storage resources are saved.
For those skilled in the art to better understand the technical solution of the present invention, the technical solution in the embodiment of the present invention will be clearly and completely described below with reference to the drawings in the embodiment of the present invention, and it is obvious that the described embodiment is only a partial embodiment of of the present invention, rather than a complete embodiment.
The invention is mainly applied to a clustered Docker container platform system, as shown in FIG. 3, a Docker management console is connected with mirror image warehouse servers and a plurality of container hosts, the mirror image warehouse servers are provided with mirror image warehouses, the container hosts can be user equipment and the like, if the application on the container hosts needs to be updated, the latest version of the mirror image file of the application is downloaded from the mirror image warehouses, and the Docker containers corresponding to the application are started as required.
images in the prior art are constructed in such a way that versions of an application are 3.0 versions, while an application developer improves certain functions on the basis of the 3.0 version of the application, the application developer upgrades the application to the 4.0 version, image files of the 1.0, 2.0 and 3.0 versions of the application exist in an image warehouse, the application developer imports an application file of the 4.0 version, and an image construction script, wherein the image construction script comprises 4 image compilation instructions, each image compilation instruction is used for constructing an image layer of application files of versions, a constructed Docker image is shown in fig. 4, an image file in the image layer 1 corresponds to the 1.0 version, an image file in the image layer 2 corresponds to the 2.0 version, an image file in the image layer 3 corresponds to the 3.0 version, and an image file in the image layer 4 (i.e., a Docker container) corresponds to the 4.0 version (i.e., the current version).
The above-described application has only 4 versions, and therefore only 4 mirror layers, but the Docker mirror hierarchy is limited to 127 layers, and when the historical versions of the application are many, merging of the mirror layers is required.
The following describes the Docker image construction method in detail by way of example.
Referring to fig. 5, embodiments of the method for constructing a Docker image according to the embodiment of the present invention include:
501. acquiring a relevant application file and a mirror image construction script of an application, wherein the mirror image construction script comprises a layer combining instruction, and the layer combining instruction comprises a target mirror image layer identifier;
in this embodiment, assuming that versions of an application need to be updated, the Docker container platform system receives an application file of a current version of the application imported by a user or acquired through a network, and a storage of the Docker container platform system includes an application file of a previous historical version of the application, so that a related application file of the application is obtained, and receives a mirror image construction script input by the user or a mirror image construction script automatically generated by the Docker container platform system, where the mirror image construction script includes a layer combining instruction ("CLEAN"), the layer combining instruction includes a target mirror layer identifier, and the layer combining instruction is used to combine a current mirror layer and a target mirror layer.
502. Compiling the mirror image of the related application file according to the mirror image construction script to obtain a Docker mirror image layer;
in this embodiment, according to the existing rule, the mirror image construction script includes at least mirror image compilation instructions, and mirror image compilation is performed on a relevant application file according to the mirror image compilation instruction in the mirror image construction script to obtain a Docker mirror image layer, assuming that the application of fig. 4 is described above, the versions are 4, and the application file includes 4 mirror image compilation instructions, where instruction 1 is used to compile version 1.0, instruction 2 is used to compile version 2.0, instruction 3 is used to compile version 3.0, and instruction 4 is used to compile version 4.0, due to the tree-like inheritance mode of the mirror image layer, the order of instruction execution is instruction 1-instruction 2-instruction 3-instruction 4 in sequence, and the combined layer instruction is located behind instruction 4, and the preset target mirror image layer is the mirror image layer of version 2.0.
503. If the current instruction is a combined-layer instruction, acquiring a mirror image file of a current mirror image layer in the Docker mirror image layer, and acquiring a mirror image file of a target mirror image layer corresponding to a target mirror image layer identifier;
in this embodiment, if the currently executed instruction is a synthetic instruction, an image file of a current image layer in the Docker image layer is obtained, where the image layer 4 in fig. 4 is the current image layer, and an image file of a target image layer corresponding to the target image layer identifier is obtained, where the target image layer is the image layer 2.
504. Obtaining a difference file according to the image file of the current image layer and the image file of the target image layer, and constructing a combined image layer according to the difference file;
in this embodiment, the difference between the image file of the current image layer (image layer 4) and the image file of the target image layer (image layer 2) is compared, assuming that the image file of the image layer 2 is an application file of version 2.0, and the application of version 4.0 is added with a voice recognition function on the basis of version 2.0, then the image file of the image layer 4 has more file contents or data related to the voice recognition function than the image file of the image layer 2, and these file contents or data are extracted and integrated to obtain a difference file, and in addition, it is also possible that the application of the new version deletes some functions on the basis of the old version application, and since the image file of the image layer 4 corresponds to the application file of version 4.0, and according to the mechanism, the image file of the image layer 2 is an application file of version 4.0 less deleted than the image file of the image layer 2, and thus the difference file is compiled according to the parent rule of the image file.
505. The combined layer mirror layer is submitted to a mirror repository.
In this embodiment, after the combined layer mirror layer is constructed, the combined layer mirror layer is submitted to the mirror repository, and the corresponding container host can obtain the mirror image file, i.e., the difference file, from the combined layer mirror layer of the mirror repository.
In the embodiment of the invention, on the basis of the prior art, by modifying the Docker source code mode, the problem of excessive mirror image levels caused by complicated mirror image construction scripts or long-term version iteration is solved, and the limitation that the Docker mirror image levels cannot exceed 127 layers is bypassed; compared with the merging mirror image layer in the prior art, the merging mirror image layer is the difference file of the mirror image files of the two mirror image layers, so that the time consumption for merging the mirror image layers later can be greatly reduced, and the efficiency is improved; compared with the prior art, the number of Docker mirror image levels is reduced, so that the interaction times between the container host and the mirror image warehouse are reduced, and the pressure of the mirror image warehouse server can be reduced due to the large number of container hosts; because the combined layer mirror image layer is the difference file obtained after the mirror image files in the two mirror image layers are compared, compared with the prior art, the data volume of the mirror image files in the combined layer mirror image layer is reduced, and the storage resources of the mirror image warehouse server and the container host are saved.
In the above embodiment, the image construction script may be input by a user or may be automatically generated, and how to obtain the image construction script is described in detail through the embodiments below.
Optionally, in embodiments of the present invention, acquiring a relevant application file and an image construction script of an application includes:
acquiring a relevant application file of an application;
determining the number of history versions of the application according to the related application files, wherein the number of the history versions is at least two;
generating mirror image compiling instructions according to the number of the historical versions, wherein the number of the mirror image compiling instructions is the same as the number of the historical versions;
determining a target mirror image layer identifier and a combined layer instruction position according to the historical version number and a preset combined layer rule;
and generating a combined layer instruction according to the target mirror layer identifier, and inserting the combined layer instruction between the mirror compiling instructions according to the combined layer instruction position to generate a mirror constructing script.
In the embodiment of the invention, after acquiring the relevant application files of the application, determining the historical version number of the application, generating mirror image compiling instructions according to the historical version number, wherein the mirror image compiling instructions are the same in number as the historical version number, determining a target mirror image layer identifier and a combined layer instruction position according to the historical version number and a preset combined layer rule, wherein the preset combined layer rule can be that when the number of mirror image layers needing to be compiled (namely the historical version number) exceeds a certain value, two mirror image layers needing to be combined are determined, the former mirror image layer is taken as the target mirror image layer, the target mirror image layer identifier (namely the name of the mirror image layer of the target version) is determined, the latter mirror image layer is taken as the current mirror image layer, namely the combined instruction position is after the mirror image compiling instruction of the current mirror image layer, generating the combined layer instruction according to the target mirror image layer identifier, and inserting the combined layer instruction between the mirror image compiling instructions according to the combined layer instruction, and generating a mirror image construction script, explaining the setting of the position of the synthesis instruction in the mirror image construction script, and defining the mirror image layer to be merged.
Optionally, in embodiments of the present invention, the obtaining a Docker image layer by performing image compilation on a relevant application file according to an image construction script includes:
acquiring a mirror image compiling instruction before a combined layer instruction in a mirror image construction script;
and executing a mirror image compiling instruction, and carrying out mirror image compiling on the related application files to obtain a Docker mirror image layer, wherein the Docker mirror image layer comprises a target mirror image layer.
In the embodiment of the invention, how the Docker management console carries out image compilation according to the image construction script is refined, so that the scheme is more specific.
Optionally, in embodiments of the present invention, obtaining an image file of a current image layer in a Docker image layer, and obtaining an image file of a target image layer corresponding to a target image layer identifier includes:
if the current instruction is a combined layer instruction, acquiring a mirror image file of a current mirror image layer in the Docker mirror image layer;
and determining a target mirror image layer from the Docker mirror image layer according to the target mirror image layer identification in the combined layer instruction, and reading out the mirror image file of the target mirror image layer from the target mirror image layer.
In the embodiment of the invention, when the currently executed instruction is a combined-layer instruction, the image file of the current image layer in the Docker image layer is obtained, the target image layer is determined from the Docker image layer according to the target image layer identifier in the combined-layer instruction, the image file in the target image layer is readable, and the image file of the target image layer is read from the target image layer.
Optionally, in embodiments of the present invention, the method for constructing a Docker image further includes:
and sending an updating instruction to the corresponding container host to enable the container host to download the image file in the synthesized image layer from the image warehouse according to the updating instruction.
In the embodiment of the invention, after the Docker mirror image is constructed, an update instruction is sent to the container host corresponding to the application, so that the container host can know the application update according to the update instruction, the mirror image file in the synthetic mirror image layer, namely the difference file, is downloaded from the mirror image warehouse in the mirror image server, the mirror image file of the latest version of the application is obtained according to the difference file, the application container based on the mirror image of the latest version is started according to the actual requirement, the application can be started by the container host, all the mirror image files of the new version application do not need to be obtained and saved, but the mirror image file for saving the difference file of the new version application and the old version application is obtained, the transmission of the data volume of the mirror image file between the mirror image warehouse and the container host is reduced, and the data volume of the mirror image file which the container host.
The foregoing embodiment describes a method for constructing a Docker image according to an embodiment of the present invention, and details of a Docker management console are described below with reference to the embodiment.
Referring to fig. 6, an embodiment of the present invention provides Docker management consoles included in a Docker container platform system, the Docker container platform system further including a mirror warehouse server and at least container hosts, including:
the acquisition module 601 is configured to acquire a relevant application file and a mirror image construction script of an application, where the mirror image construction script includes a layer combining instruction, and the layer combining instruction includes a target mirror image layer identifier;
the mirror image compiling module 602 is configured to compile a mirror image of the relevant application file according to the mirror image construction script to obtain a Docker mirror image layer;
a mirror image file obtaining module 603, configured to, when the current instruction is a combined-layer instruction, obtain a mirror image file of a current mirror image layer in the Docker mirror image layer, and obtain a mirror image file of a target mirror image layer corresponding to the target mirror image layer identifier, where the current mirror image layer is located above the target mirror image layer;
the combined layer module 604 is configured to obtain a difference file according to the image file of the current image layer and the image file of the target image layer, and construct a combined image layer according to the difference file;
a mirror submission module 605 configured to submit the combined layer mirror layer to a mirror repository in the mirror repository server.
In the embodiment of the present invention, when the mirror compiling module 602 executes the combined-layer instruction, all the mirror layers between the current mirror layer and the target mirror layer are combined into combined-layer mirror layers, and the combined-layer mirror layers are the difference files of the mirror files of the two mirror layers.
Optionally, as shown in fig. 7, in embodiments of the present invention, the obtaining module 601 includes a obtaining unit 701 and an instruction generating unit 702;
an obtaining unit 701, configured to obtain a relevant application file of an application;
an instruction generating unit 702, configured to determine, according to the relevant application file, the number of history versions of the application, where the number of history versions is at least two;
the instruction generating unit 702 is further configured to generate mirror image compiling instructions according to the number of the historical versions, where the number of the mirror image compiling instructions is the same as the number of the historical versions;
the instruction generating unit 702 is further configured to determine a target mirror layer identifier and a combined layer instruction position according to the historical version number and a preset combined layer rule;
the instruction generating unit 702 is further configured to generate a combined layer instruction according to the target mirror layer identifier, and insert the combined layer instruction between the mirror compiling instructions according to the combined layer instruction position, so as to generate a mirror image building script.
In the embodiment of the present invention, after the obtaining unit 701 obtains the relevant application file of the application, the instruction generating unit 702 determines the number of the historical versions of the application, the instruction generating unit 702 generates the mirror image compiling instruction according to the number of the historical versions, the number of the mirror image compiling instruction is the same as the number of the historical versions, the target mirror image layer identifier and the position of the combined layer instruction are determined according to the number of the historical versions and the preset combined layer rule, the preset combined layer rule may be that when the number of the mirror image layers to be compiled (i.e. the number of the historical versions) exceeds a certain value, the instruction generating unit 702 determines two mirror image layers to be combined, the front mirror image layer is used as the target mirror image layer, the instruction generating unit 702 determines the target mirror image layer identifier (i.e. the name of the mirror image layer of the target version), the rear mirror image layer is used as the current mirror layer, i.e. the position of the, and generating a combined layer instruction according to the target mirror layer identifier, inserting the combined layer instruction between mirror compiling instructions according to the combined layer instruction position to generate a mirror constructing script, explaining the setting of the position of the combining instruction in the mirror constructing script, and defining the mirror layers to be combined.
Optionally, as shown in fig. 7, in embodiments of the present invention, the mirror compiling module 602 includes an instruction obtaining unit 703 and an instruction executing unit 704;
an instruction obtaining unit 703, configured to obtain a mirror compiling instruction before a layer-combining instruction in the mirror construction script;
and the instruction execution unit 704 is configured to execute the mirror image compiling instruction, perform mirror image compiling on the relevant application file, and obtain a Docker mirror layer, where the Docker mirror layer includes a target mirror layer.
In the embodiment of the present invention, how the mirror image file obtaining module 603 performs mirror image compilation according to the mirror image construction script is refined, so that the scheme is more specific.
Alternatively, as shown in fig. 7, in embodiments of the invention,
the image file obtaining module 603 is specifically configured to obtain an image file of a current image layer in the Docker image layer when the current instruction is a combined-layer instruction;
the mirror image file obtaining module 603 is further configured to determine a target mirror image layer from the Docker mirror image layer according to the target mirror image layer identifier in the combined-layer instruction, and read out the mirror image file of the target mirror image layer from the target mirror image layer.
In this embodiment of the present invention, when the currently executed instruction is a combined-layer instruction, the image file obtaining module 603 obtains an image file of a current image layer in the Docker image layer, determines a target image layer from the Docker image layer according to a target image layer identifier in the combined-layer instruction, where the image file in the target image layer is readable, and reads the image file of the target image layer from the target image layer.
Optionally, as shown in fig. 7, in embodiments of the present invention, the Docker management console further includes a sending module 705;
and the sending module is used for sending the updating instruction to the container host corresponding to the application, so that the container host downloads the image file in the synthesized image layer from the image warehouse according to the updating instruction.
In the embodiment of the present invention, after the Docker image is constructed, the sending module 705 sends an update instruction to the container host corresponding to the application, so that the container host can know application update according to the update instruction, download the difference file from the image repository, obtain the image file of the latest version of the application according to the difference file, start the application container based on the image of the latest version according to actual needs, so that the container host can start the application, and obtain and store all image files of the new version application without obtaining and storing all image files of the new version application, but obtain and store the image file of the difference file of the new version application and the old version application, reduce transmission of data volume of the image file between the image repository and the container host, and reduce data volume of the image file that the container host needs to store. .
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, devices and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units into logical functional divisions may be realized in other ways, for example, multiple units or components may be combined or integrated into another systems, or features may be omitted or not executed, in another point, the shown or discussed coupling or direct coupling or communication connection between each other may be through interfaces, indirect coupling or communication connection between the apparatuses or units may be electrical, mechanical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, that is, may be located in places, or may also be distributed on multiple network units.
In addition, the functional units in the embodiments of the present invention may be integrated into processing units, or each unit may exist alone physically, or two or more units are integrated into units.
Based on the understanding, the technical solution of the present invention, which is essentially or partially contributed to by the prior art, or all or part of the technical solution, may be embodied in the form of a software product stored in storage media, which includes several instructions for causing computer devices (which may be personal computers, servers, or network devices) to execute all or part of the steps of the methods according to the embodiments of the present invention.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (8)

1, Docker mirror image construction method, characterized by comprising:
acquiring a relevant application file and a mirror image construction script of an application, wherein the mirror image construction script comprises a combined layer instruction, and the combined layer instruction comprises a target mirror image layer identifier;
compiling the mirror image of the related application file according to the mirror image construction script to obtain a Docker mirror image layer;
if the current instruction is the combined layer instruction, acquiring a mirror image file of a current mirror image layer in the Docker mirror image layer, and acquiring a mirror image file of a target mirror image layer corresponding to the target mirror image layer identifier, wherein the current mirror image layer is positioned above the target mirror image layer;
obtaining a difference file according to the image file of the current image layer and the image file of the target image layer, and constructing a combined image layer according to the difference file, wherein the difference file is a file or data associated with the difference function between the current image layer and the target image layer;
submitting the combined layer mirror layer to a mirror repository;
and sending an updating instruction to the container host corresponding to the application, so that the container host downloads the image file in the combined image layer from the image warehouse according to the updating instruction.
2. The Docker image construction method according to claim 1, wherein the obtaining of the relevant application file and image construction script of the application comprises:
acquiring a relevant application file of an application;
determining the number of historical versions of the application according to the related application files, wherein the number of the historical versions is at least two;
generating mirror image compiling instructions according to the historical version number, wherein the mirror image compiling instructions are the same as the historical version number;
determining a target mirror image layer identifier and a combined layer instruction position according to the historical version number and a preset combined layer rule;
generating a combined layer instruction according to the target mirror layer identification, inserting the combined layer instruction between the mirror compiling instructions according to the combined layer instruction position, and generating a mirror constructing script.
3. The Docker mirror image construction method according to claim 2, wherein the obtaining of the Docker mirror image layer by mirror-compiling the relevant application file according to the mirror image construction script comprises:
acquiring a mirror image compiling instruction before the combined layer instruction in the mirror image construction script;
and executing the mirror image compiling instruction, and carrying out mirror image compiling on the related application files to obtain a Docker mirror image layer, wherein the Docker mirror image layer comprises a target mirror image layer.
4. The Docker mirror image construction method according to claim 3, wherein the obtaining of the mirror image file of the current mirror image layer in the Docker mirror image layer and the obtaining of the mirror image file of the target mirror image layer corresponding to the target mirror image layer identifier comprises:
if the current instruction is the combined layer instruction, acquiring a mirror image file of a current mirror image layer in the Docker mirror image layer;
and determining a target mirror image layer from the Docker mirror image layer according to the target mirror image layer identification in the combined layer instruction, and reading out the mirror image file of the target mirror image layer from the target mirror image layer.
The Docker management console of , wherein the Docker management console is included in a Docker container platform system, the Docker container platform system further having a mirror warehouse server, the Docker management console comprising:
an acquisition module, configured to acquire an application file and a mirror image construction script related to an application, where the mirror image construction script includes a combined layer instruction, and the combined layer instruction includes a target mirror image layer identifier;
the mirror image compiling module is used for carrying out mirror image compiling on the related application files according to the mirror image construction script to obtain a Docker mirror image layer;
the image file acquisition module is used for acquiring an image file of a current image layer in the Docker image layer and acquiring an image file of a target image layer corresponding to the target image layer identification when the current instruction is the combined layer instruction, wherein the current image layer is positioned above the target image layer;
the layer combining module is used for obtaining a difference file according to the image file of the current image layer and the image file of the target image layer, and constructing a layer combining image layer according to the difference file, wherein the difference file is a file or data related to the difference function between the current image layer and the target image layer;
the mirror image submitting module is used for submitting the combined mirror image layer to a mirror image warehouse in the mirror image warehouse server;
and the sending module is used for sending an updating instruction to the container host corresponding to the application, so that the container host downloads the image file in the combined image layer from the image warehouse according to the updating instruction.
6. The Docker management console of claim 5, wherein the th obtaining module comprises an obtaining unit and an instruction generating unit;
the acquisition unit is used for acquiring the relevant application files of the application;
the instruction generating unit is used for determining the number of the historical versions of the application according to the related application files, and the number of the historical versions is at least two;
the instruction generating unit is further configured to generate mirror image compiling instructions according to the historical version number, and the number of the mirror image compiling instructions is the same as the historical version number;
the instruction generating unit is further used for determining a target mirror image layer identifier and a combined layer instruction position according to the historical version number and a preset combined layer rule;
the instruction generating unit is further configured to generate a combined layer instruction according to the target mirror layer identifier, and insert the combined layer instruction between the mirror compiling instructions according to the combined layer instruction position to generate a mirror constructing script.
7. The Docker management console of claim 6, wherein the mirror compilation module comprises: an instruction acquisition unit and an instruction execution unit;
the instruction obtaining unit is used for obtaining a mirror image compiling instruction before the combined layer instruction in the mirror image construction script;
the instruction execution unit is configured to execute the mirror image compiling instruction, perform mirror image compiling on the relevant application file, and obtain a Docker mirror image layer, where the Docker mirror image layer includes a target mirror image layer.
8. The Docker management console of claim 7, wherein,
the image file obtaining module is specifically configured to obtain an image file of a current image layer in the Docker image layer when the current instruction is the combined-layer instruction;
the image file obtaining module is further configured to determine a target image layer from the Docker image layer according to the target image layer identifier in the combined layer instruction, and read an image file of the target image layer from the target image layer.
CN201610546234.5A 2016-07-12 2016-07-12 Docker container construction method and Docker management console Active CN106227579B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610546234.5A CN106227579B (en) 2016-07-12 2016-07-12 Docker container construction method and Docker management console

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610546234.5A CN106227579B (en) 2016-07-12 2016-07-12 Docker container construction method and Docker management console

Publications (2)

Publication Number Publication Date
CN106227579A CN106227579A (en) 2016-12-14
CN106227579B true CN106227579B (en) 2020-01-31

Family

ID=57519081

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610546234.5A Active CN106227579B (en) 2016-07-12 2016-07-12 Docker container construction method and Docker management console

Country Status (1)

Country Link
CN (1) CN106227579B (en)

Families Citing this family (42)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106802807B (en) * 2017-02-20 2020-07-24 深圳市冬泉谷信息技术有限公司 Application delivery method based on container platform, container platform and application delivery system
CN106933635B (en) * 2017-03-15 2020-06-30 北京搜狐新媒体信息技术有限公司 Docker mirror image generation method and Docker container
CN107105054B (en) * 2017-05-17 2019-12-24 苏州浪潮智能科技有限公司 Mirror image garbage cleaning system and method for docker mirror image warehouse
CN107491329B (en) * 2017-08-04 2021-03-16 上海携程商务有限公司 Docker mirror image construction method, device, storage medium and electronic device
CN107544824B (en) * 2017-08-09 2021-02-09 北京华宇信息技术有限公司 New project delivery distribution package, generation and operation method and readable storage medium
CN107577475B (en) * 2017-08-22 2020-02-07 清华大学 Software package management method and system of data center cluster system
CN107643918B (en) * 2017-09-19 2021-07-02 郑州云海信息技术有限公司 Container management method and device
CN109542493A (en) * 2017-09-22 2019-03-29 华为技术有限公司 A kind of image upgrade method and apparatus
CN107608735A (en) * 2017-09-27 2018-01-19 郑州云海信息技术有限公司 A kind of container mirror image integrated approach and its device
CN107809467B (en) * 2017-10-10 2020-06-16 暨南大学 Method for deleting container mirror image data in cloud environment
US10606805B2 (en) 2017-11-16 2020-03-31 Red Hat, Inc. Object-level image query and retrieval
CN109901816A (en) * 2017-12-08 2019-06-18 中国科学院上海高等研究院 Co-development method, terminal, medium and the system of protection copyright based on container
CN108170514A (en) * 2017-12-19 2018-06-15 中国科学院声学研究所 A kind of container operation method and device
US10970258B2 (en) 2018-02-23 2021-04-06 Red Hat, Inc. Managing container-image layers
US10719345B2 (en) 2018-05-16 2020-07-21 International Business Machines Corporation Container image building
CN110955431B (en) * 2018-09-27 2024-02-13 北京国双科技有限公司 Processing method and device of compiling environment
CN109783191B (en) * 2018-12-18 2020-09-08 全球能源互联网研究院有限公司 Management, use and construction method and device of container mirror image
CN111352726B (en) * 2018-12-24 2024-04-05 三六零科技集团有限公司 Stream data processing method and device based on containerized micro-service
WO2020232713A1 (en) * 2019-05-23 2020-11-26 Microsoft Technology Licensing, Llc Container instantiation with union file system layer mounts
US11182193B2 (en) 2019-07-02 2021-11-23 International Business Machines Corporation Optimizing image reconstruction for container registries
CN110543311B (en) * 2019-09-05 2024-01-23 曙光信息产业(北京)有限公司 Mirror image construction method, device and storage medium
CN110908686B (en) * 2019-11-15 2023-08-29 西安雷风电子科技有限公司 Container mirror image replacement method
CN111045783B (en) * 2019-11-20 2023-12-15 东软集团股份有限公司 Method and device for generating container mirror image, storage medium and electronic equipment
CN111190687B (en) * 2019-11-28 2023-06-30 安超云软件有限公司 Method, device, equipment and storage medium for constructing container mirror image
CN111078364A (en) * 2019-12-19 2020-04-28 浪潮云信息技术有限公司 Method for realizing small-volume basic mirror image
CN111078229A (en) * 2019-12-20 2020-04-28 北京天融信网络安全技术有限公司 Application processing method and device, storage medium and electronic equipment
CN111131449B (en) * 2019-12-23 2021-03-26 华中科技大学 Method for constructing service clustering framework of water resource management system
US11500980B2 (en) 2020-02-11 2022-11-15 International Business Machines Corporation Automated and auditable framework to control software component changes in an application build process
US11243758B2 (en) 2020-02-13 2022-02-08 International Business Machines Corporation Cognitively determining updates for container based solutions
CN111459490B (en) * 2020-03-11 2023-05-05 云知声智能科技股份有限公司 Voice recognition engine transplanting method and device capable of automatically adapting to hardware platform
CN111459611A (en) * 2020-03-27 2020-07-28 新浪网技术(中国)有限公司 Mirror image pulling method and device for Kubernetes system
CN111459668A (en) * 2020-03-30 2020-07-28 中科边缘智慧信息科技(苏州)有限公司 Lightweight resource virtualization method and device for server
CN111432006B (en) * 2020-03-30 2023-03-31 中科九度(北京)空间信息技术有限责任公司 Lightweight resource virtualization and distribution method
US11429596B2 (en) 2020-04-20 2022-08-30 International Business Machines Corporation Update for configuration file
CN111522627B (en) * 2020-04-26 2023-11-28 杭州威佩网络科技有限公司 Docker mirror image management method, device, equipment and medium
CN114428661A (en) * 2020-10-29 2022-05-03 华为技术有限公司 Mirror image management method and device
CN112383606B (en) * 2020-11-09 2023-12-19 福建亿榕信息技术有限公司 Desktop container mirror image increment P2P distribution method and device
CN112612489B (en) * 2020-12-16 2024-03-12 北京梆梆安全科技有限公司 Method and device for constructing upgrade package of software and electronic equipment
CN112799711B (en) * 2021-01-29 2022-04-05 广州文远知行科技有限公司 Method and device for merging container images, computer equipment and storage medium
CN113209633B (en) * 2021-06-09 2023-07-07 腾讯科技(深圳)有限公司 Mirror image processing method and device, electronic equipment and readable storage medium
CN113342378B (en) * 2021-06-25 2022-08-02 浪潮通用软件有限公司 Mirror image generation method, device and medium based on file system update
CN116225625B (en) * 2023-05-11 2023-08-08 天津金城银行股份有限公司 Application container management method, system, computer and readable storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103023990B (en) * 2012-11-28 2016-06-08 迈普通信技术股份有限公司 Image file upgrade-system in pile system and method
CN105490860B (en) * 2015-12-24 2019-03-05 北京奇虎科技有限公司 The method, apparatus and system of disposing application program running environment
CN105653449A (en) * 2015-12-28 2016-06-08 湖南蚁坊软件有限公司 Continuous integration method based on container virtualization
CN105740038B (en) * 2016-02-02 2019-04-23 浙江工业大学 A kind of storage optimization method of internet of things oriented reprogramming

Also Published As

Publication number Publication date
CN106227579A (en) 2016-12-14

Similar Documents

Publication Publication Date Title
CN106227579B (en) Docker container construction method and Docker management console
US10908887B2 (en) Dynamic container deployment with parallel conditional layers
US11573776B1 (en) Extensible data transformation authoring and validation system
KR101963912B1 (en) Application compatibility with library operating systems
US8972967B2 (en) Application packages using block maps
KR101793306B1 (en) Virtual application extension points
US10929149B2 (en) Method and system for updating firmware
US10592354B2 (en) Configurable recovery states
WO2019079080A1 (en) Using semantic annotations to control compatibility behaviors
WO2020180546A1 (en) Deferred path resolution during container deployment
CN115543224B (en) ZNS SSD-based file system control method, device and equipment
CN115291946A (en) Hongmong system transplanting method, device, electronic equipment and readable medium
CN114756290A (en) Operating system installation method, device and readable storage medium
Stewart SkiffOS: Minimal cross-compiled linux for embedded containers
US10564894B2 (en) Free space pass-through
US20180341475A1 (en) Just In Time Deployment with Package Managers
CN114860202A (en) Project operation method, device, server and storage medium
US20240152371A1 (en) Dynamic re-execution of parts of a containerized application pipeline
TWI777636B (en) Method, device, and computer program product for composing modular firmware
US20240143992A1 (en) Hyperparameter tuning with dynamic principal component analysis
CN115878197A (en) Starting optimization method, system, chip, device and medium based on device tree
CN115857968A (en) Operating system installation method and device
CN114089973A (en) Starting method, starting device, computer equipment and storage medium
CN117369840A (en) Method for constructing embedded operating system based on customized software source
CN114185556A (en) Intelligent contract deployment method, device, equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant