Container mirror image optimization method and device, equipment and storage medium

By parsing and optimizing container images, identifying and eliminating redundant information, the problem of excessive storage resource consumption by container images is solved, and efficient utilization of storage resources is achieved.

CN121597337APending Publication Date: 2026-03-03BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411153043.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-21
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

In existing technologies, container images consume a significant amount of system storage resources. How to reduce their storage resource consumption while ensuring normal operation is a technical problem that needs to be solved.

Method used

By parsing and processing the container image, redundant information is identified and eliminated, optimization decisions are generated, including deleting useless files and merging image layers, and rebuilding the optimized image.

Benefits of technology

It effectively reduces the size of container images, lowers their storage resource consumption, and optimizes storage space utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597337A_ABST
    Figure CN121597337A_ABST
Patent Text Reader

Abstract

The invention relates to a container mirror image optimization method and device, equipment and a storage medium. The container mirror image is analyzed, an analysis result is obtained, and the analysis result comprises redundant information of the container mirror image; determining an optimization decision of the container mirror image based on the redundant information; the container mirror image is optimized based on the optimization decision, so that redundancy in the container mirror image can be eliminated, the size of the container mirror image is reduced, and the occupation of the container mirror image on storage resources is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of container image optimization technology, and in particular to a container image optimization method, apparatus, device and storage medium. Background Technology

[0002] Container images are a lightweight, portable form of software packaging. A container image contains the application and all its dependencies, configuration, and runtime environment. However, in practice, container images consume system storage resources, which are limited. Therefore, reducing the storage resource consumption of container images while ensuring their proper functioning is a key technical challenge. Summary of the Invention

[0003] To solve the above-mentioned technical problems, or at least partially solve them, this disclosure provides a container image optimization method, apparatus, device, and storage medium.

[0004] In a first aspect, embodiments of this disclosure provide a container image optimization method, the method comprising:

[0005] Obtain the container image;

[0006] The container image is parsed to obtain a parsing result, which contains redundant information of the container image.

[0007] Based on the redundant information, an optimization decision for the container image is determined;

[0008] The container image is optimized based on the optimization decision to eliminate redundancy in the container image.

[0009] Optionally, the step of parsing the container image to obtain the parsing result includes:

[0010] Based on a preset parsing model, the dependencies, structure, and components of the container image are parsed to obtain at least one of the following redundant information in the container image:

[0011] Useless files, removable dependencies, and mergeable image layers.

[0012] Optionally, determining the optimization decision for the container image based on the redundancy information includes:

[0013] The accuracy of the redundant information is evaluated based on a preset evaluation model.

[0014] Optimized decisions are generated based on redundant information with an accuracy higher than a preset threshold.

[0015] Optionally, the optimization decision includes at least one of the following decisions:

[0016] Delete files and / or dependencies, merge image layers.

[0017] Optionally, optimizing the container image based on the optimization decision includes:

[0018] Based on the optimization decision, redundant content contained in the container image is eliminated;

[0019] After eliminating the redundant content, the container image is rebuilt, and the information of the rebuilt container image is cached, wherein the cached information includes at least one of the following: components, dependencies, structure, and version number.

[0020] Secondly, embodiments of this disclosure provide a container image optimization apparatus, comprising:

[0021] The acquisition module is used to acquire container images;

[0022] The parsing module is used to parse the container image to obtain a parsing result, which contains redundant information of the container image.

[0023] The determination module is used to determine the optimization decision for the container image based on the redundancy information;

[0024] An optimization module is used to optimize the container image based on the optimization decision to eliminate redundancy in the container image.

[0025] Optionally, the parsing module is used for:

[0026] Based on a preset parsing model, the dependencies, structure, and components of the container image are parsed to obtain at least one of the following redundant information in the container image:

[0027] Useless files, removable dependencies, and mergeable image layers.

[0028] Optionally, the determining module is used to:

[0029] The accuracy of the redundant information is evaluated based on a preset evaluation model.

[0030] Optimized decisions are generated based on redundant information with an accuracy higher than a preset threshold.

[0031] Optionally, the optimization decision includes at least one of the following decisions:

[0032] Delete files and / or dependencies, merge image layers.

[0033] Optionally, the optimization module is used for:

[0034] Based on the optimization decision, redundant content contained in the container image is eliminated;

[0035] After eliminating the redundant content, the container image is rebuilt, and the information of the rebuilt container image is cached, wherein the cached information includes at least one of the following: components, dependencies, structure, and version number.

[0036] Thirdly, embodiments of this disclosure provide a computer device, including:

[0037] Memory;

[0038] Processor; and

[0039] Computer programs;

[0040] The computer program is stored in the memory and configured to be executed by the processor to implement the method as described in the first aspect.

[0041] Fourthly, embodiments of this disclosure provide a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the method described in the first aspect.

[0042] The container image optimization method, apparatus, device, and storage medium provided in this disclosure, after obtaining a container image, perform parsing processing on the container image to obtain a parsing result, the parsing result containing redundant information of the container image; based on the redundant information, determine the optimization decision of the container image; and optimize the container image based on the optimization decision, can eliminate redundancy in the container image, reduce the size of the container image, and reduce the container image's occupation of storage resources. Attached Figure Description

[0043] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0044] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 This is a flowchart of a container image optimization method provided in an embodiment of this disclosure;

[0046] Figure 2This is a flowchart of a container image optimization method provided in an embodiment of this disclosure;

[0047] Figure 3 This is a schematic diagram of the structure of a container image optimization device provided in an embodiment of this disclosure;

[0048] Figure 4 This is a schematic diagram of the structure of a computer device embodiment provided in this disclosure. Detailed Implementation

[0049] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0050] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.

[0051] Example, Figure 1 This is a flowchart of a container image optimization method provided in an embodiment of this disclosure. This method can be executed by a computer device, which can be understood, exemplarily, as a device with computing power, such as a server, distributed computing node, etc., but is not limited to servers and distributed computing nodes. Figure 1 As shown, the method provided in this disclosure includes:

[0052] Step 101: Obtain the container image.

[0053] The container image referred to in this disclosure contains information such as the application and all its dependencies, configuration, and runtime environment.

[0054] For example, in one feasible implementation, the container image can be obtained from a pre-defined storage device or storage area.

[0055] For example, in another feasible implementation, the container image may also be sent directly to the aforementioned computer device after the image device has imaged the container.

[0056] It is understood that the two methods for obtaining container images described above are merely exemplary and not the only methods. In other implementations, other methods may be used depending on the actual working conditions. For the sake of clarity, they will not be listed here.

[0057] Step 102: Parse the container image to obtain the parsing result, which contains redundant information about the container image.

[0058] In one exemplary implementation, embodiments of this disclosure can perform static and dynamic parsing of container images to identify dependencies, components, and structures within the container image. For example, in one feasible implementation, the container image can first be run using container runtime technology provided by related technologies. After the container image runs successfully, a pre-configured static parsing tool can be used to parse the container image and obtain its dependencies, components, and structures. The aforementioned static parsing tool can be configured or written as needed, and is not limited to a specific static parsing tool.

[0059] Furthermore, after obtaining the dependencies, components, and structure in the container image, the dependencies (such as databases or function libraries), components, and structure (such as installation directories) in the container image can be analyzed based on a preset analysis model to obtain redundant information in the container image, such as useless files, removable dependencies, and mergeable image layers (for example, image layers with the same instructions can be merged).

[0060] For example, in another feasible implementation, a parsing model can be pre-trained based on model training methods provided by related technologies. This parsing model can then parse components, dependencies, and structures within the container image to obtain redundant information (such as useless files, removable dependencies, or mergeable image layers). In other words, the model is trained with the container image as input and outputs redundant information from the container image.

[0061] Furthermore, in some implementations, after obtaining the redundant information in the container image, a container image analysis report and / or a JSON-formatted metadata structure corresponding to the container image analysis report can also be generated.

[0062] Step 103: Based on redundant information, determine the optimization decision for the container image.

[0063] In one embodiment, the optimization decision referred to in this disclosure can be understood as a decision to eliminate all redundant items contained in the redundant information. For example, when the redundant information contains information about useless files, information about removable dependencies, and information about mergeable mirror layers, the optimization decision may include deleting the aforementioned useless files and dependencies, and merging the aforementioned mergeable mirror layers.

[0064] In another feasible implementation, when determining optimization decisions, the accuracy of redundant information can first be evaluated based on a preset evaluation model. Based on the evaluation results, optimization decisions are generated for redundant information with accuracy exceeding a preset threshold, such as deleting files and / or dependencies, or merging at least one of image layers. For example, if the redundant information includes information about useless files and removable dependencies, the information about useless files and removable dependencies, along with the container image, can be input into the evaluation model. The evaluation model determines the probability (i.e., accuracy) that the aforementioned files are useless, and the probability that dependencies can be deleted. If the probability is higher than a preset threshold, a decision to delete the aforementioned useless files and dependencies can be generated. If the probability that the aforementioned files are useless is higher than the preset threshold, and the probability that dependencies can be deleted is lower than the preset threshold, an optimization decision to delete the aforementioned useless files is generated, and the aforementioned dependencies are not deleted. It should be noted that the above evaluation model is trained based on container image samples, as well as the availability labels, dependency deletability labels, and image layer merging labels of the samples. The training method can be found in related technologies and will not be elaborated here.

[0065] Step 104: Optimize the container image based on optimization decisions to eliminate redundancy in the container image.

[0066] Example, Figure 2 This is a flowchart of a container image optimization method provided in an embodiment of this disclosure. Figure 2 As shown, in one embodiment, the method for optimizing a container image based on an optimization strategy may include steps 201-202.

[0067] Step 201: Based on optimization decisions, eliminate redundant content contained in the container image.

[0068] For example, in one implementation, the optimization decision is to delete file a and dependency b, and merge image layers c and d. In this case, file a and dependency b are deleted from the container image, and image layers c and d are merged into one image layer.

[0069] Step 202: After eliminating redundant content, rebuild the container image and cache the information of the rebuilt container image, wherein the cached information includes at least one of the following: components, dependencies, structure, and version number.

[0070] For example, in one exemplary implementation, an open-source continuous integration / continuous deployment (CI / CD) method can be used to rebuild the optimized container image. Information about the rebuilt container image, such as components, dependencies, structure, version number, image name, and size, is stored in a cache.

[0071] Furthermore, based on the above-mentioned caching, the information of container images stored in the cache can be compared periodically. For example, the version number of the same container image can be compared, the information of the old version of the container image can be deleted, and the information of the latest version of the container image can be retained, thereby saving cache space.

[0072] In this embodiment, after obtaining a container image, the container image is parsed to obtain a parsing result containing redundant information about the container image. Based on the redundant information, an optimization decision is determined for the container image. Based on the optimization decision, the container image is optimized to eliminate redundancy.

[0073] Figure 3 This is a schematic diagram of a container image optimization device provided in an embodiment of this disclosure. This container image optimization device can be exemplarily understood as the computer device in the above embodiments or some functional modules of the computer device described above. For example... Figure 3 As shown, the container image optimization device 30 includes:

[0074] Module 31 is used to obtain the container image;

[0075] The parsing module 32 is used to parse the container image to obtain a parsing result, the parsing result containing redundant information of the container image;

[0076] The determination module 33 is used to determine the optimization decision of the container image based on the redundancy information;

[0077] The optimization module 34 is used to optimize the container image based on the optimization decision to eliminate redundancy in the container image.

[0078] Optionally, the parsing module is used for:

[0079] Based on a preset parsing model, the dependencies, structure, and components of the container image are parsed to obtain at least one of the following redundant information in the container image:

[0080] Useless files, removable dependencies, and mergeable image layers.

[0081] Optionally, the determining module is used to:

[0082] The accuracy of the redundant information is evaluated based on a preset evaluation model.

[0083] Optimized decisions are generated based on redundant information with an accuracy higher than a preset threshold.

[0084] Optionally, the optimization decision includes at least one of the following decisions:

[0085] Delete files and / or dependencies, merge image layers.

[0086] Optionally, the optimization module is used for:

[0087] Based on the optimization decision, redundant content contained in the container image is eliminated;

[0088] After eliminating the redundant content, the container image is rebuilt, and the information of the rebuilt container image is cached, wherein the cached information includes at least one of the following: components, dependencies, structure, and version number.

[0089] The specific execution method and beneficial effects of the container image optimization device provided in this embodiment can be found in the above method embodiments, and will not be repeated here.

[0090] Figure 4 This is a schematic diagram of the structure of a computer device embodiment provided in this disclosure. For example... Figure 4 As shown, the computer device includes a memory 121 and a processor 122.

[0091] Memory 121 is used to store programs. In addition to programs, memory 121 can also be configured to store various other data to support operation on the computer device. Examples of such data include instructions for any application or method used on the computer device, images, videos, etc.

[0092] The memory 121 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0093] The processor 122 is coupled to the memory 121 and executes the program stored in the memory 121 for:

[0094] Obtain the container image;

[0095] The container image is parsed to obtain a parsing result, which contains redundant information of the container image.

[0096] Based on the redundant information, an optimization decision for the container image is determined;

[0097] The container image is optimized based on the optimization decision to eliminate redundancy in the container image.

[0098] Furthermore, such as Figure 4As shown, the computer device may also include other components such as a communication component 123, a power supply component 124, an audio component 125, and a display 126. Figure 4 The diagram only shows some components and does not mean that the computer device includes only these components. Figure 4 The components shown.

[0099] Communication component 123 is configured to facilitate wired or wireless communication between computer devices and other devices. The computer devices can access wireless networks based on communication standards, such as WiFi, 2G, or 3G, or combinations thereof. In one exemplary embodiment, communication component 123 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 123 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0100] Power supply component 124 provides power to various components of the computer device. Power supply component 124 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the computer device.

[0101] Audio component 125 is configured to output and / or input audio signals. For example, audio component 125 includes a microphone (MIC) configured to receive external audio signals when the computer device is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 121 or transmitted via communication component 123. In some embodiments, audio component 125 also includes a speaker for outputting audio signals.

[0102] Display 126 includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touchscreen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation.

[0103] Communication component 123, power supply component 124, audio component 125, display 126 and other components can be connected via a bus to complete communication with each other.

[0104] A bus can be hardware, software, or both. For example, and not limited to, a bus can include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industrial Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Where appropriate, a bus can include one or more buses.

[0105] In addition, this disclosure also provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the container image optimization method described in the above embodiments.

[0106] The aforementioned storage medium may, for example, include a memory for computer program instructions, which can be executed by a processor of a computer device to perform the methods described in the embodiments of this disclosure. Optionally, the storage medium may be a non-transitory computer-readable storage medium, such as a ROM, random access memory (RAM), compact disc-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device.

[0107] This disclosure also provides an exemplary embodiment of a computer program product, including a computer program, wherein, when executed by a computer's processor, the computer program is used to cause the computer to execute in order to implement the container image optimization method described in the above embodiments.

[0108] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0109] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A container image optimization method, characterized in that, The method includes: Obtain the container image; The container image is parsed to obtain a parsing result, which contains redundant information of the container image. Based on the redundant information, an optimization decision for the container image is determined; The container image is optimized based on the optimization decision to eliminate redundancy in the container image.

2. The method according to claim 1, characterized in that, The process of parsing the container image to obtain the parsing result includes: Based on a preset parsing model, the dependencies, structure, and components of the container image are parsed to obtain at least one of the following redundant information in the container image: Useless files, removable dependencies, and mergeable image layers.

3. The method according to claim 1, characterized in that, The step of determining the optimization decision for the container image based on the redundancy information includes: The accuracy of the redundant information is evaluated based on a preset evaluation model. Optimized decisions are generated based on redundant information with an accuracy higher than a preset threshold.

4. The method according to claim 3, characterized in that, The optimization decision includes at least one of the following decisions: Delete files and / or dependencies, merge image layers.

5. The method according to any one of claims 1-4, characterized in that, The optimization process for the container image based on the optimization decision includes: Based on the optimization decision, redundant content contained in the container image is eliminated; After eliminating the redundant content, the container image is rebuilt, and the information of the rebuilt container image is cached, wherein the cached information includes at least one of the following: components, dependencies, structure, and version number.

6. A container image optimization device, characterized in that, include: The acquisition module is used to acquire container images; The parsing module is used to parse the container image to obtain a parsing result, which contains redundant information of the container image. The determination module is used to determine the optimization decision for the container image based on the redundancy information; An optimization module is used to optimize the container image based on the optimization decision to eliminate redundancy in the container image.

7. The apparatus according to claim 6, characterized in that, The parsing module is used for: Based on a preset parsing model, the dependencies, structure, and components of the container image are parsed to obtain at least one of the following redundant information in the container image: Useless files, removable dependencies, and mergeable image layers.

8. The apparatus according to claim 6, characterized in that, The determining module is used for: The accuracy of the redundant information is evaluated based on a preset evaluation model. Optimized decisions are generated based on redundant information with an accuracy higher than a preset threshold.

9. The apparatus according to claim 8, characterized in that, The optimization decision includes at least one of the following decisions: Delete files and / or dependencies, merge image layers.

10. The apparatus according to any one of claims 6-9, characterized in that, The optimization module is used for: Based on the optimization decision, redundant content contained in the container image is eliminated; After eliminating the redundant content, the container image is rebuilt, and the information of the rebuilt container image is cached, wherein the cached information includes at least one of the following: components, dependencies, structure, and version number.

11. A computer device, wherein, include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and configured to be executed by the processor to implement the method as described in any one of claims 1-5.

12. A computer-readable storage medium having a computer program stored thereon, wherein, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-5.