A container image management method and management system

By hierarchically managing container images based on file update frequency and adopting the incremental update method, the problem of resource waste when updating container images is solved and the efficiency of image management and update is improved.

CN117369947BActive Publication Date: 2024-08-30SHENZHEN HAIGUI NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311404895.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-26
Publication Date
2024-08-30
Estimated Expiration
2043-10-26

AI Technical Summary

Technical Problem

When an existing container image is updated, only part of the application is modified, and the entire application layer needs to be downloaded completely, resulting in a waste of time and network resources.

Method used

Carry out hierarchical management based on the update frequency of application files, adopt the incremental update method, update only the difference files, reuse the unupdated layers, and build container images.

Benefits of technology

It improves the management and update efficiency of container images, reduces update time and network resource usage, and achieves more efficient image management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117369947B
    Figure CN117369947B
Patent Text Reader

Abstract

The present invention discloses a container image management method and management system, which belongs to the field of electronic digital data processing technology. The management method includes an image generation method: obtaining files required for executing an application and the update frequency of the files; classifying the files according to the update frequency; establishing a container image hierarchy according to the classification to obtain the image. The container image hierarchy is constructed and organized according to the file update frequency; when updating the image, the unupdated hierarchy can be reused, and only the corresponding hierarchy of the difference file is updated; the management and update efficiency of the image is improved, and the update time and network resource occupation are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronic digital data processing, and in particular to a container image management method and management system. Background Art

[0002] A container image can create multiple containers, which are application instances created using an image. Therefore, container images have high reusability. Container images are usually built in layers. During the development of Docker technology, a common method of creating images is to put the entire application in a separate layer. This method is simple and intuitive. However, there are certain shortcomings when updating images: for example, when the application is only partially modified or updated, the entire application layer needs to be fully downloaded when rebuilding the image, which will waste time and network resources. Therefore, it is necessary to design an efficient method for managing container images. Summary of the invention

[0003] In view of the above technical problems existing in the prior art, the present invention provides a container image management method and management system, which are layered based on the update frequency of application-related files to improve the management efficiency of images.

[0004] The present invention discloses a container image management method, including an image generation method: obtaining files required for executing an application and the update frequency of the files; classifying the files according to the update frequency; and establishing a container image hierarchy according to the classification to obtain the image.

[0005] Preferably, the mirror update method is:

[0006] Based on the incremental update method, a difference file between the first image and the first target image is obtained;

[0007] Determining a first level to be updated according to the difference file;

[0008] Get the unupdated second level from the first image;

[0009] According to the first level and the second level, a first target image is obtained.

[0010] Preferably, files with an update frequency lower than the threshold value are placed in the lower layer, and files with an update frequency higher than the threshold value are placed in the upper layer;

[0011] The level to be updated includes the level corresponding to the difference file and the level above it.

[0012] Preferably, the image includes any of the following layers or a combination thereof: a basic framework layer, a stable dependency layer, a snapshot dependency layer, a resource file layer, and an application code layer.

[0013] The basic framework layer is used to store the basic framework of the application;

[0014] The stable dependency layer is used to store the stable libraries and related components that the application depends on;

[0015] The snapshot dependency layer is used to store the snapshot library and its related components that the application depends on;

[0016] The resource file layer is used to store static files and configuration files;

[0017] The application code layer is used to store the core code of the application program.

[0018] Preferably, the method for establishing a hierarchy based on a packaging tool includes:

[0019] Create folders for each category;

[0020] According to the classification, the files are placed into corresponding folders;

[0021] Using the files in the folder, a hierarchy is constructed.

[0022] Preferably, a method of constructing a hierarchy using configuration files:

[0023] According to the classification of the files, a configuration file is established, wherein the configuration file includes a mapping relationship between the layers and the files;

[0024] According to the mapping relationship, the files are placed into folders of corresponding categories;

[0025] According to the mapping relationship, a hierarchy is constructed using corresponding files in corresponding folders.

[0026] Preferably, the image of the application includes a first code layer and a second code layer, and the method of constructing the first code layer and the second code layer includes:

[0027] According to the update frequency of the application, the code of the application is split into a first code and a second code, and corresponding first code files and second code files are created;

[0028] Constructing a first code layer according to the first code file;

[0029] constructing a second code layer according to the second code file;

[0030] According to the reference relationship between the first code and the second code, a hierarchical relationship between the first code layer and the second code layer is established.

[0031] Preferably, the method for incrementally building a target image includes:

[0032] Obtain the difference file between the first image and the target image;

[0033] Determining a first level to be constructed according to the difference file;

[0034] Get the unupdated second level from the first image;

[0035] Build the target image based on the first level and the second level.

[0036] The present invention also provides a management system for implementing the above management method, comprising an update frequency acquisition module, a classification module and a hierarchy construction module;

[0037] The update frequency update module is used to obtain the files required for executing the application and the update frequency of the files;

[0038] The classification module is used to classify the files according to the update frequency;

[0039] The hierarchical construction module is used to establish a hierarchy of container images according to the classification and obtain the images.

[0040] Preferably, the management system further includes an image update module, the image update module being used to: obtain a difference file between the first image and the first target image based on an incremental update method;

[0041] Determining a first level to be updated according to the difference file;

[0042] Get the unupdated second level from the first image;

[0043] According to the first level and the second level, a first target image is obtained.

[0044] Compared with the prior art, the beneficial effects of the present invention are: building and organizing the layers of container images according to the update frequency of files; when updating the image, the unupdated layers can be reused and only the corresponding layers of the difference files are updated; the management and update efficiency of the image is improved, and the update time and network resources occupied are reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 is a flow chart of a method for generating a container image of the present invention;

[0046] Figure 2 It is a logic block diagram of the management system of the present invention. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0048] The present invention is further described in detail below in conjunction with the accompanying drawings:

[0049] A container image management method includes an image generation method, an incremental update method, and an incremental build method. Figure 1 , the image generation method includes:

[0050] Step 101: Obtain files required for executing the application and the update frequency of the files, which can be obtained based on testing or experience.

[0051] Step 102: Classify the files according to the update frequency.

[0052] Step 103: According to the classification, a hierarchy of container images is established to obtain images.

[0053] Step 201: Based on the incremental update method, obtain the difference file between the first image and the first target image. Specifically, the first image is the local old version image, and the first target image is the image to be downloaded in the server.

[0054] Step 202: Determine the level to be updated based on the difference file. Specifically, determine the level to be updated based on the classification of the difference file.

[0055] Step 203: Obtain the first layer to be updated from the first target image, and obtain the second layer that has not been updated from the first image.

[0056] Step 204: Obtain a first target image according to the first level and the second level.

[0057] Build and organize the layers of container images according to the update frequency of files; when updating images, reuse the layers that have not been updated and only update the corresponding layers of the difference files; improve the management and update efficiency of images and reduce update time and network resource usage.

[0058] Specifically, in the hierarchical organization of the container image, files / layers with an update frequency lower than the threshold value are set at the lower layer, and files / layers with an update frequency higher than the threshold value are set at the lower layer; the layer to be updated includes the corresponding layer of the difference file and the layer above it. Since the upper layer has a higher update frequency, when updating the image, the corresponding layer and the upper layer are updated at the same time, which can improve the accuracy of the image update and avoid errors.

[0059] In a specific embodiment, the image includes any of the following layers or a combination thereof: a basic framework layer, a stable dependency layer, a snapshot dependency layer, a resource file layer, and an application code layer. The basic framework layer is used to store the basic framework of the application; the stable dependency layer is used to store the stable library and its related components that the application depends on; the snapshot dependency layer is used to store the snapshot library and its related components that the application depends on; the resource file layer is used to store static files and configuration files; and the application code layer is used to store the core code of the application. But it is not limited to this. Developers can organize the image layer organization more flexibly.

[0060] Methods for incrementally building a target image include:

[0061] Step 301: Obtain a difference file between a first image and a target image.

[0062] Step 302: Determine the first level to be constructed according to the difference file.

[0063] Step 303: Obtain the unupdated second layer, or the layer above it, from the first image.

[0064] Step 304: Build a target image based on the first level and the second level.

[0065] Through incremental construction, computing resources can be saved and the efficiency of image generation can be improved.

[0066] A hierarchy may also be established based on a packaging tool: a folder is established for each classification; the files are placed into corresponding folders according to the classification; and a hierarchy is constructed using the files in the folders.

[0067] More specifically, the configuration file is used to build the hierarchy:

[0068] Step 401: Create a configuration file based on the classification of files, where the configuration file includes a mapping relationship between layers and files.

[0069] For example, a key-value configuration file is used to describe the mapping relationship between the layer name and the files contained in the layer. The key represents a layer name, and the value represents the set of file paths contained in the layer.

[0070] Step 402: According to the mapping relationship, the file is placed into a folder of a corresponding category.

[0071] Step 403: According to the mapping relationship, a hierarchy is constructed using corresponding files in corresponding folders.

[0072] The packaging tool copies the files to the corresponding hierarchical folders according to the mapping relationship in the configuration file, and references these files as needed during the image building process.

[0073] Application developers can flexibly define their own layering strategies based on actual conditions. They can freely organize and adjust the layered structure based on the characteristics and requirements of the project and the best practices for building Docker images. For different applications, developers can adopt different layered organization methods to meet personalized needs. This flexible layered design not only improves the customizability of container (Docker) images, but also enables application developers to better control and manage the size, build speed, and operating efficiency of the image.

[0074] For example, for a Spring Boot application, the configuration file of the packaging tool can be:

[0075] -Basic framework layer

[0076] -"org / springframework / boot / loader / "

[0077] -Stable dependency layer

[0078] -"BOOT-INF / lib / *RELEASE.jar"

[0079] -Snapshot dependency layer

[0080] -"BOOT-INF / lib / *SNAPSHOT.jar"

[0081] - Resource file layer

[0082] -"static / "

[0083] - Application code layer

[0084] -"BOOT-INF / classes / "

[0085] Among them, the first layer is the basic framework layer, which contains the files of the Spring Boot framework; the second layer is the stable dependency layer, which contains stable dependency files, such as the jar package files of the RELEASE version, which change very rarely; the third layer is the snapshot dependency layer, which contains snapshot version dependency files, such as the jar package files of the SNAPSHOT version, which are usually dependencies related to development and testing and can be updated over time; the fourth layer is the resource file layer, which contains static resource files; the fifth layer is the application code layer, which contains the code and resource files of the application itself.

[0086] In another embodiment, according to the image of the application program including a first code layer and a second code layer, and their update frequencies are different, a method for constructing the first code layer and the second code layer includes:

[0087] Step 501: according to the update frequency of the application, the code of the application is split into a first code and a second code, and corresponding first code files and second code files are created.

[0088] Step 502: construct a first code layer according to the first code file; construct a second code layer according to the second code file.

[0089] Step 503: According to the reference relationship between the first code and the second code, a hierarchical relationship between the first code layer and the second code layer is established, and an application image is constructed.

[0090] By updating the frequency and packaging the application code in layers, the hierarchical management of the application code is achieved.

[0091] The present invention also provides a management system for implementing the above management method, such as Figure 2 As shown, it includes an update frequency acquisition module 1, a classification module 2 and a hierarchy construction module 3.

[0092] The update frequency update module 1 is used to obtain the files required to execute the application and the update frequency of the files;

[0093] The classification module 2 is used to classify the files according to the update frequency;

[0094] The layer construction module 3 is used to establish the layer of container images according to the classification and obtain the images.

[0095] The management system also includes an image update module 4, which is used to: obtain a difference file between the first image and the first target image based on an incremental update method; determine a first level to be updated based on the difference file; obtain an unupdated second level from the first image; and obtain a first target image based on the first level and the second level.

[0096] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for managing container images, characterized in that: Including the image generation method: Obtaining files required to execute the application and the update frequency of said files; Classifying the files according to the update frequency; According to the classification, multiple layers of container images are established to obtain images, and files with update frequencies lower than a threshold are set in a lower layer, and files with update frequencies higher than the threshold are set in an upper layer; The mirror image updating method comprises: Based on the incremental update method, a difference file between the first image and the first target image is obtained; Determine a first level to be updated according to the difference file, wherein the first level to be updated includes a level corresponding to the difference file and a level above it; Get the unupdated second level from the first image; According to the first level and the second level, a first target image is obtained; The image includes a combination of the following layers: basic framework layer, stable dependency layer, snapshot dependency layer, resource file layer and application code layer. The basic framework layer is used to store the basic framework of the application; The stable dependency layer is used to store the stable libraries and related components that the application depends on; The snapshot dependency layer is used to store the snapshot library and its related components that the application depends on; The resource file layer is used to store static files and configuration files; The application code layer is used to store the core code of the application program.

2. The management method according to claim 1, characterized in that: Methods for building layers based on packaging tools include: Create folders for each category; According to the classification, the files are placed into corresponding folders; Using the files in the folder, a hierarchy is constructed.

3. The management method according to claim 2, characterized in that: It also includes methods for building hierarchies using configuration files: According to the classification of the files, a configuration file is established, wherein the configuration file includes a mapping relationship between the layers and the files; According to the mapping relationship, the files are placed into folders of corresponding categories; According to the mapping relationship, a hierarchy is constructed using corresponding files in corresponding folders.

4. The management method according to claim 1, characterized in that: The image of the application includes a first code layer and a second code layer, and the method of constructing the first code layer and the second code layer includes: According to the update frequency of the application, the code of the application is split into a first code and a second code, and corresponding first code files and second code files are created; Constructing a first code layer according to the first code file; constructing a second code layer according to the second code file; According to the reference relationship between the first code and the second code, a hierarchical relationship between the first code layer and the second code layer is established.

5. The management method according to claim 1, characterized in that: Methods for incrementally building a target image include: Obtain the difference file between the first image and the target image; Determining a first level to be constructed according to the difference file; Get the unupdated second level from the first image; Build the target image based on the first level and the second level.

6. A management system, characterized in that: A method for managing container images according to any one of claims 1 to 5, wherein the system comprises an update frequency acquisition module, a classification module and a hierarchy construction module; The update frequency acquisition module is used to acquire the files required for executing the application and the update frequency of the files; The classification module is used to classify the files according to the update frequency; The hierarchical construction module is used to establish a hierarchy of container images according to the classification and obtain the images.

7. The management system according to claim 6, characterized in that: It also includes an image update module, which is used to: obtain a difference file between the first image and the first target image based on an incremental update method; Determining a first level to be updated according to the difference file; Get the unupdated second level from the first image; According to the first level and the second level, a first target image is obtained.

Citation Information

Patent Citations

  • Docker mirror image construction method and device

    CN110704156A

  • Asset data processing method, related device and storage medium

    CN116383223A