A container image reuse optimization method based on content reconstruction
By identifying and providing shared and unique content to container images in stages, the problem of ineffective utilization of duplicate file content across images is solved, thereby improving the deployment efficiency and resource utilization efficiency of container images.
Patent Information
- Application Number
- CN202610788107.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-03
- Publication Date
- 2026-08-25
AI Technical Summary
Existing container image reuse methods cannot effectively identify and utilize duplicate file content across images, leading to increased network, storage, and computing overhead. Furthermore, when local storage on nodes is limited, it is difficult to distinguish between critical and non-critical startup content, affecting container startup speed and resource utilization efficiency.
By restoring the final visible file view of the target image, the shared content that appears repeatedly across the target image is identified. Combined with the access characteristics during the container startup phase, the image content is divided into startup shared content, startup unique content, delayed shared content, and delayed unique content. A reconstructed image is generated, and the startup content layer is prioritized for acquisition and assembly during node deployment, so that the container enters the ready state, while the acquisition and assembly of the delayed content layer is delayed.
It improves the reuse efficiency of container images, shortens the image provisioning path before containers are ready, reduces the overhead of repeated unpacking and disk writing, optimizes node resource utilization, and improves image deployment efficiency.
Smart Images

Figure CN122633200A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of cloud-native computing and container image management technology, specifically involving a container image reuse optimization method, system, and electronic device based on content reconstruction. Background Technology
[0002] Container images are the standard format for packaging container applications. As a static template used to create container instances, a container image contains the code, runtime environment, dependency files, library files, and configuration parameters required to run an application. Container images are typically formed by stacking multiple image layers sequentially. When deploying a container, a node needs to retrieve the corresponding image layer from the image repository and perform verification, unpacking, and assembly. With the development of application scenarios such as microservices, elastic scaling, rolling updates, and edge deployment, the repeated pulling, unpacking, and disk writing of container images significantly increases network, storage, and computational overhead, thereby affecting container startup speed and node resource utilization efficiency.
[0003] Existing container image reuse methods typically judge based on the entire image layer. A node can only directly reuse an existing image layer if the layer digests of two image layers are completely identical. In practice, different images or different versions of the same image often contain a large number of identical system libraries, runtime files, and dependency files. However, these identical files may be distributed across different image layers due to differences in build order, layer partitioning methods, or version evolution paths, resulting in different image layer digests and thus failing to be recognized and utilized by existing layer-based reuse mechanisms.
[0004] Furthermore, not all content in a container image is accessed during the container startup phase. Some content is critical startup material that must be acquired and assembled before the container enters the ready state, while other content can be added after the container enters the ready state. Existing methods often include the entire image content in the critical path before the container is ready, causing non-critical content to consume network transmission, unpacking, and assembly resources. At the same time, when node local storage capacity is limited, traditional cache replacement methods mainly select objects to be evicted based on access time or access frequency, making it difficult to distinguish between startup-critical content and ordinary deferred content, and also making it difficult to reliably retain shared content with high reuse value across images.
[0005] Therefore, how to reconstruct the duplicate file content across images into a reusable image content structure without changing the basic usage of container images, and how to combine the access characteristics of the container startup phase for phased provisioning and local reuse, is a technical problem that needs to be solved to improve the deployment efficiency of container images. Summary of the Invention
[0006] The purpose of this invention is to address the aforementioned deficiencies in the prior art and provide a container image reuse optimization method, system, and electronic device based on content reconstruction. This method restores the final visible file view of the target image, identifies shared content that repeatedly appears across target images, and categorizes the image content into different types based on access patterns during container startup. Then, it reconstructs the image content and deployment order according to these categories, thereby improving container image reuse efficiency and shortening the image provisioning path before the container is ready.
[0007] The first objective of this invention can be achieved by adopting the following technical solution:
[0008] A container image reuse optimization method based on content reconstruction, the container image reuse optimization method includes the following steps:
[0009] S1. Parse each target image in the target image set and restore the final visible file view of each target image according to the image layer overlay semantics and deletion semantics;
[0010] S2. Based on the final visible file view of each target image, identify the shared content of files that appear repeatedly across target images to obtain a set of shared content and a set of unique content.
[0011] S3. Obtain the file content accessed by each target image during the container startup phase, form a startup access set, and divide the image content into startup shared content, startup unique content, delayed shared content, and delayed unique content based on the shared content set, unique content set, and startup access set.
[0012] S4. Reconstruct the target image according to the startup shared content, startup unique content, delayed shared content, and delayed unique content to generate a reconstructed image containing the startup content layer and the delayed content layer.
[0013] S5. When deploying a reconstructed image on a node, prioritize acquiring and assembling the startup content layer to bring the container into a ready state. After the container enters the ready state, continue to acquire and assemble the delayed content layer, and reuse the shared content already available on the node during the deployment process to complete the optimized deployment of container image reuse.
[0014] Furthermore, step S1 addresses the issue that the presence of overwritten, deleted, and intermediate files in the original image layer leads to inaccurate identification of shared content based solely on the original image layer. Specifically, the file content that is truly visible in the target image under the final runtime semantics is first restored, and this result is then used as the basis for subsequent shared content identification; the process is as follows:
[0015] S11. Read the file objects in each original image layer according to the arrangement order of the original image layers in the target image, and record the file path, file type and content summary of the file objects;
[0016] S12. When the upper-level file object and the lower-level file object have the same file path, retain the upper-level file object according to the mirror layer overwrite semantics, and remove the lower-level file object with the same path from the visible results.
[0017] S13. When there are deletion marks in the original image layer, remove the deleted file objects or file objects in the masked directory according to the deletion marks to obtain the final visible file view of the target image.
[0018] Through the above processing, the final visible file view retains only the valid file content that is actually visible at container runtime. This can eliminate the interference of original image layer partitioning differences, overwrite semantics, and deletion semantics on shared identification, and provide an accurate data foundation for subsequent cross-target image content reuse.
[0019] Furthermore, in step S2, the process of obtaining the shared content set and the unique content set is as follows:
[0020] S21. Using the content summary corresponding to the file content as the basis for judgment, compare the file objects in the final visible file view of each target image;
[0021] S22. File objects that appear in two or more target images and have the same content digest are identified as shared content, and the shared content is added to the shared content set;
[0022] S23. Identify file objects that appear only in one target image as unique content, and add the unique content to the unique content set.
[0023] Step S2 addresses the issue that existing hierarchical reuse methods only work when the entire image layer digest is completely identical. Because runtime files, dependency files, or system tools with identical content in different target images may be distributed across different original image layers, resulting in different image layer digests and preventing reuse. This invention, based on the final visible file views of each target image, uses the content digest corresponding to the file content as the criterion for content consistency. When file objects with the same content digest appear in two or more target images, the file content corresponding to that file object is identified as shared content and added to the shared content set; when a file object appears in only one target image, the file content corresponding to that file object is identified as unique content and added to the unique content set. Its working principle is to use the content digest to characterize whether the file content is consistent, rather than using the original image layer digest to characterize whether it can be reused. Therefore, it can discover cross-target image duplicate content hidden by the boundaries of the original image layers, improving the cross-target image content reuse capability.
[0024] Furthermore, step S3 is as follows:
[0025] S31. Start the container instance corresponding to the target image in the controlled environment, and record the file content accessed from the moment the container starts until the moment the application inside the container is ready to provide services to the outside world, forming a startup access set.
[0026] S32. Compare the shared content set and the unique content set with the startup access set respectively. Classify the content that belongs to both the shared content set and the startup access set as startup shared content, and classify the content that belongs to both the unique content set and the startup access set as startup unique content.
[0027] S33. Classify content that belongs to the shared content set but not to the initial access set as delayed shared content, and classify content that belongs to the unique content set but not to the initial access set as delayed unique content.
[0028] Through the above processing, the image content possesses both cross-target image reuse attributes and startup phase access attributes. Based on this working principle, startup shared content and startup-specific content are identified as the content to be prioritized for provisioning before the container is ready, while delayed shared content and delayed-specific content are identified as the content to be supplemented after the container is ready, thereby reducing the amount of data that needs to be processed before the container is ready.
[0029] Step S3 addresses the issue of non-critical startup content being included in the container-ready path, causing it to consume transmission, unpacking, and assembly resources. Specifically, it offline identifies the file content actually accessed before the container is ready and combines the access attributes of this startup phase with the shared attributes to obtain four types of image content that can be used for subsequent phased provisioning.
[0030] In step S3, the process of obtaining the access set is initiated as follows:
[0031] S301. Start the container instance corresponding to the target image in a controlled environment;
[0032] S302. From the moment the container starts up until the moment the application inside the container is ready to provide services to the outside world after initialization, record the contents of the files accessed during this time period.
[0033] S303. The recorded file contents are combined into a boot access set for the target image.
[0034] In step S3, the process of dividing the mirrored content into startup shared content, startup unique content, delayed shared content, and delayed unique content is as follows:
[0035] S311. The content that belongs to both the shared content set and the startup access set is classified as startup shared content;
[0036] S312. The content that belongs to both the unique content set and the startup access set is classified as startup unique content;
[0037] S313. Content that belongs to the shared content set but does not belong to the initial access set is classified as delayed shared content;
[0038] S314. Content that belongs to the unique content set but does not belong to the start access set is classified as delayed unique content.
[0039] Furthermore, step S4 addresses the issue that file-level sharing identification results are difficult to directly use during node deployment. Simply identifying shared file content does not directly improve node deployment efficiency; it is also necessary to transform shared content, unique content, and access relationships during the startup phase into an image organization format that can be identified and used during image deployment. The process is as follows:
[0040] S41. Organize the shared startup content and the unique startup content into a startup content layer, and organize the delayed shared content and the delayed unique startup content into a delayed content layer.
[0041] S42. Identify the same shared content in different target images using the same content digest, so that nodes can identify and reuse the shared content based on the content digest;
[0042] S43. Rewrite the image list according to the order in which the startup content layer is located before the delayed content layer to obtain the reconstructed image.
[0043] Through the above processing, the layer order in the image manifest is used to express the content provisioning priority, and the content summary is used to express the identity of shared content. This enables nodes to identify, during deployment, which content should be provisioned first, which content can be supplemented later, and which content can be reused across multiple target images. Based on this working principle, this invention organizes duplicate file content across target images into an image content structure that is accessible, assembleable, and reusable by nodes, while maintaining the semantics of the final file system of the target image.
[0044] Furthermore, step S5 is used to address the issues of repeatedly acquiring shared content and non-startup critical content blocking container readiness during node deployment. This invention transforms the image deployment process from a one-time full processing to a phased processing around the container readiness path, and stores the results of one acquisition and one unpacking of shared content in the node's local content library for reuse in subsequent deployments; the process is as follows:
[0045] S51. After receiving the deployment request for the image to be deployed, the node parses the image list of the reconstructed image and processes the startup content layer first.
[0046] S52. For shared startup content in the startup content layer, if content with the same content digest already exists in the node's local content library, the content in the node's local content library is directly reused; if content with the same content digest does not exist in the node's local content library, the corresponding content is obtained from the mirror repository and written to the node's local content library.
[0047] S53. For startup-specific content in the startup content layer, write it to the dedicated directory of the current image to be deployed, and assemble the startup content layer according to the image layer overwrite semantics and deletion semantics to put the container into a ready state.
[0048] S54. After the container enters the ready state, continue to acquire and assemble the deferred content layer.
[0049] Through the above processing, nodes only need to prioritize the startup content layer before the container is ready, and the delayed content layer will no longer block the container from entering the ready state; at the same time, the startup shared content can be reused through the node's local content library, thereby reducing the overhead of repeated fetching, repeated unpacking and repeated disk writing on the node side.
[0050] In step S5, the process of deploying and reconstructing the image on the node is as follows:
[0051] S501. After receiving the deployment request for the image to be deployed, the node parses the image list of the reconstructed image and processes the startup content layer first.
[0052] S502. For shared startup content in the startup content layer, if content with the same content digest already exists in the node's local content library, the content in the node's local content library is directly reused; if content with the same content digest does not exist in the node's local content library, the corresponding content is obtained from the mirror repository and written to the node's local content library.
[0053] S503. For startup-specific content in the startup content layer, write it to the dedicated directory of the current image to be deployed.
[0054] S504. Assemble the startup content layer according to the mirror layer overlay semantics and deletion semantics, so that the container enters the ready state;
[0055] S505. After the container enters the ready state, continue to acquire and assemble the deferred content layer.
[0056] Furthermore, during the process of deploying and reconstructing the node image, the content objects in the node's local content library are cached and replaced, as follows:
[0057] S511. When the local storage capacity of a node is insufficient to write new content objects, exclude content objects that are being downloaded, verified, unpacked, assembled, or used by the deployment path before the container is ready.
[0058] S512. Among the remaining content objects, determine the retention priority in ascending order of delayed unique content, delayed shared content, initiated unique content, and initiated shared content.
[0059] S513. Prioritize selecting content objects to be evicted from content objects with lower retention priority, and within the same retention priority, select content objects to be evicted based on the access time and the number of repeated accesses.
[0060] S514. If no content object can be evicted, the new content object is only used temporarily for the purposes of this deployment and is not written to the node's local content library.
[0061] Cache replacement during node deployment and image reconstruction addresses the challenge of reliably retaining high-value content under limited local storage capacity. Node-local content repositories are not unlimited. When new content objects need to be written and remaining capacity is insufficient, replacing them solely based on access time or frequency might evict content objects currently in the deployment path or startup shared content more valuable for subsequent deployments. Therefore, this invention excludes content objects currently being downloaded, verified, unpacked, assembled, or used in pre-container-ready deployment paths before selecting evictable objects. It then determines retention priorities in ascending order: delayed unique content, delayed shared content, startup unique content, and startup shared content. Within the same retention priority, it further considers access time and frequency of repeated access to select evictable objects. The working principle is that content category reflects the value of content objects for container-ready paths and cross-target image reuse, while activity status reflects whether content objects are currently participating in the deployment process. Based on this principle, this invention can prioritize the protection of startup-critical content and reusable shared content while freeing up local storage space, reducing the interference of cache replacement on the current deployment process and improving the reuse benefits of the node-local content repository.
[0062] The second objective of this invention can be achieved by adopting the following technical solution:
[0063] A content-based container image reuse optimization system, applied to the aforementioned content-based container image reuse optimization method, the system comprising:
[0064] The parsing and recovery view module is used to parse each target image in the target image set and restore the final visible file view of each target image according to the image layer overlay semantics and deletion semantics;
[0065] The content set identification module is used to identify the shared content set and the unique content set by identifying the file content that appears repeatedly across target images based on the final visible file view of each target image.
[0066] The image content partitioning module is used to obtain the file content accessed by each target image during the container startup phase, form a startup access set, and divide the image content into startup shared content, startup unique content, delayed shared content, and delayed unique content based on the shared content set, unique content set, and startup access set.
[0067] The target image reconstruction module is used to reconstruct the target image according to the startup shared content, startup unique content, delayed shared content, and delayed unique content, generating a reconstructed image containing the startup content layer and the delayed content layer.
[0068] The container image deployment module is optimized. When deploying and reconstructing an image on a node, the startup content layer is acquired and assembled first to put the container into a ready state. After the container enters the ready state, the delayed content layer is acquired and assembled, and the existing shared content on the node is reused during the deployment process to complete the optimized deployment of container image reuse.
[0069] The third objective of this invention can be achieved by adopting the following technical solution:
[0070] An electronic device, the electronic device comprising:
[0071] At least one processor; and,
[0072] A memory that is communicatively connected to at least one processor; wherein,
[0073] The memory stores computer program instructions that can be executed by at least one processor, such that the at least one processor can perform a content-based container image reuse optimization method as described in any one of claims 1-8.
[0074] The present invention has the following advantages and beneficial effects compared with the prior art:
[0075] (1) This invention does not rely directly on the original image layer summary to determine whether it can be reused. Instead, it first restores the final visible file view of the target image and then identifies the shared content that appears repeatedly across the target image from the file content level. This can discover the repeated content that is covered by the boundary of the original image layer and improve the cross-image reuse capability.
[0076] (2) This invention combines sharing and startup phase access features, and divides the image content into startup shared content, startup unique content, delayed shared content and delayed unique content, so that the content that must be used before the container is ready is supplied first, and non-critical content is continued to be supplemented after the container is ready, thereby reducing the data acquisition and assembly overhead before the container is ready.
[0077] (3) The present invention reorganizes the image content and image list according to four categories of content, so that the shared content can be reused through the local content library of the node, and the unique content still maintains the exclusive semantics of the current image, thereby reducing the overhead of repeated unpacking and repeated disk writing while ensuring the correct semantics of the image operation.
[0078] (4) When the local storage capacity of the node is insufficient, the present invention prioritizes the protection of shared content at startup and content objects used in the deployment path, reduces the interference of cache replacement on the container ready path, and improves the image supply efficiency in the scenario of repeated deployment on the node side. Attached Figure Description
[0079] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0080] Figure 1 This is a schematic diagram of the overall process of a content-based container image reuse optimization method disclosed in this invention;
[0081] Figure 2 This is a schematic diagram illustrating the division of four types of image content and the generation of reconstructed images in this invention;
[0082] Figure 3 This is a schematic diagram of the phased provisioning and local reuse of the node deployment and reconstruction image in this invention;
[0083] Figure 4 This is a comparison chart of the sharing ratio before and after the reconstruction of the mirrored content in Embodiment 2 of the present invention;
[0084] Figure 5 This is a graph showing the average byte percentage of the four types of mirrored content during the activation of the sensing function in Embodiment 2 of the present invention;
[0085] Figure 6 This is a comparison chart of average mirror deployment time and node local content library hit rate in Embodiment 2 of the present invention. Detailed Implementation
[0086] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.
[0087] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.
[0088] Example 1
[0089] like Figure 1As shown, this embodiment takes an image set containing multiple target images as the processing object. First, in the offline stage, the visible content of the target image is restored, the shared content is identified, the startup access analysis is performed, and the reconstructed image is generated. Then, in the node deployment stage, the startup content is prioritized for provisioning, the delayed content is supplemented in the background, and the local shared content of the node is reused.
[0090] The container image reuse optimization method in this embodiment includes the following steps:
[0091] S1. Parse each target image in the target image set and restore the final visible file view of each target image according to the image layer overlay semantics and deletion semantics;
[0092] S2. Based on the final visible file view of each target image, identify the shared content of files that appear repeatedly across target images to obtain a set of shared content and a set of unique content.
[0093] S3. Obtain the file content accessed by each target image during the container startup phase, form a startup access set, and divide the image content into startup shared content, startup unique content, delayed shared content, and delayed unique content based on the shared content set, unique content set, and startup access set.
[0094] S4. Reconstruct the target image according to the startup shared content, startup unique content, delayed shared content, and delayed unique content to generate a reconstructed image containing the startup content layer and the delayed content layer.
[0095] S5. When deploying a reconstructed image on a node, prioritize acquiring and assembling the startup content layer to bring the container into a ready state. After the container enters the ready state, continue to acquire and assemble the delayed content layer, and reuse the shared content already available on the node during the deployment process to complete the optimized deployment of container image reuse.
[0096] The following combination Figures 1 to 3 The above steps will be further explained below.
[0097] In step S1, the file system ultimately seen by the node at runtime is not a simple superposition of file objects in the original image layers, but rather the result of upper-layer files overwriting lower-layer files at the same path and deletion marking. Therefore, in this embodiment, file objects are read according to the arrangement order of the original image layers in the target image, and invisible file objects are removed based on image layer overlay semantics and deletion semantics to obtain the final visible file view that each target image is actually visible at container runtime. This step ensures that subsequent share identification is performed only on runtime valid file content, avoiding misjudging overwritten or deleted files as reusable content.
[0098] In step S2, this embodiment uses the content digest corresponding to the file content as the basis for judging content consistency, and compares file objects in different target images. If file objects with the same content digest appear in more than two target images, they are identified as shared content; if a file object appears in only one target image, it is identified as unique content. This step can extract duplicate file content that could not be recognized by the hierarchical cache due to inconsistent image layer boundaries, providing a set of shared content and a set of unique content for subsequent image reconstruction.
[0099] In step S3, as Figure 2 As shown, this embodiment starts a container instance corresponding to the target image in a controlled environment, records the file content accessed by the container from the start time to the ready time, forming a start access set. Subsequently, the start access set is compared with the shared content set and the unique content set, respectively, to obtain four categories of image content: start shared content, start unique content, delayed shared content, and delayed unique content. Among these, start shared content and start unique content are content that needs to be prioritized before the container is ready, while delayed shared content and delayed unique content are content that can be supplemented after the container is ready.
[0100] In step S4, as Figure 2 As shown, this embodiment organizes shared startup content and unique startup content into a startup content layer, and delayed shared content and unique startup content into a delayed content layer. Identical shared content in different target images is identified using the same content digest, enabling it to be recognized and reused at the node level. The image list is then rewritten according to the order in which the startup content layer precedes the delayed content layer, resulting in a reconstructed image. This step transforms the file-level shared identification results into an image organization form that nodes can acquire, assemble, and reuse.
[0101] In step S5, as Figure 3 As shown, when a node receives a deployment request for an image to be deployed, it first parses and reconstructs the image manifest, prioritizing the startup content layer. For shared startup content, the node first checks if content with the same content digest already exists in its local content repository. If it exists, it reuses it directly; otherwise, it retrieves it from the image repository and writes it to the node's local content repository. For startup-specific content, the node writes it to the dedicated directory of the image to be deployed. After the node completes the assembly of the startup content layer, it puts the container into a ready state. After the container enters the ready state, it continues to retrieve and assemble the deferred content layer to complete the image content.
[0102] When a node's local storage capacity is insufficient, the node first excludes content objects that are being downloaded, verified, unpacked, assembled, or used by deployment paths before the container is ready. Then, it determines the retention priority in ascending order of delayed unique content, delayed shared content, startup unique content, and startup shared content, prioritizing the selection of content objects to be evicted from the content objects with the lowest retention priority. If no content objects can be evicted, the new content objects are only used temporarily for the current deployment and are not written to the node's local content repository.
[0103] In summary, this embodiment fully replicates each step in claim 1. Based on the above process, duplicate file content across target images is transformed into a reusable shared content structure for nodes. Startup-critical content is prioritized for inclusion in the pre-container-ready provisioning path, while non-startup-critical content is supplemented after the container is ready. Therefore, it can reduce the overhead of duplicate transmission, duplicate unpacking, and pre-container-ready image provisioning.
[0104] Example 2
[0105] This embodiment, based on Embodiment 1, verifies the technical effects of the present invention from three aspects: the effect of mirror content reconstruction, the effect of startup-aware content segmentation, and the effect of node-side deployment. The same final visible file view restoration, shared content identification, startup access set acquisition, four types of mirror content segmentation, reconstructed image generation, and node-side phased deployment processes are performed as in Embodiment 1.
[0106] like Figure 4 As shown, the sharing ratio is significantly improved after the mirror content is reconstructed. In cross-mirror sharing scenarios, the average shareable file ratio before reconstruction was 10.25%, which increased to 31.30% after reconstruction; in adjacent version sharing scenarios, the average shared content ratio before reconstruction was 5.71%, which increased to 97.19% after reconstruction. This result indicates that, by restoring the final visible file view and comparing content summaries, this invention can discover duplicate file content that is ignored by existing hierarchical reuse mechanisms due to differences in the original mirror layer boundaries, and organize it into reusable shared content.
[0107] like Figure 5 As shown, among the average byte percentages of the four types of startup-aware content, startup shared content accounts for 4.28%, startup-specific content accounts for 18.98%, delayed shared content accounts for 32.05%, and delayed-specific content accounts for 44.70%. Specifically, startup shared content and startup-specific content together account for approximately 23.26%, and delayed shared content and delayed-specific content together account for approximately 76.74%. This result indicates that the content that truly needs to be prioritized before the container is ready only constitutes a portion of the image content. Furthermore, shared content and startup criticality are not equivalent. Therefore, classifying image content into startup shared content, startup-specific content, delayed shared content, and delayed-specific content is necessary.
[0108] like Figure 6 As shown in section (a), this invention can reduce the average image deployment time under low bandwidth, medium bandwidth, and high bandwidth network conditions. Taking low bandwidth as an example, the average image deployment times for the default tiered pull method, the file-level sharing method, and this invention are 37.41 seconds, 31.75 seconds, and 29.22 seconds, respectively; for medium bandwidth, they are 22.11 seconds, 17.20 seconds, and 15.09 seconds, respectively; and for high bandwidth, they are 9.07 seconds, 8.62 seconds, and 8.22 seconds, respectively. These results demonstrate that prioritizing content layer provisioning and delaying content layer background completion can shorten the critical path before the container is ready.
[0109] like Figure 6 As shown in section (b), under the condition of limited local storage capacity on the node, the cache replacement process adopted in this invention can improve the effective hit rate of the local content library on the node. The request hit rate and byte hit rate are 28.35% and 34.78% respectively when replacing based on access recentity; the request hit rate and byte hit rate are 40.11% and 42.64% respectively when replacing based on access frequency; and the request hit rate and byte hit rate of this invention are 52.33% and 46.99% respectively. This result shows that replacing based on content category and deployment path activity status can more stably retain high-value shared content and startup-critical content under limited capacity conditions.
[0110] comprehensive Figures 4 to 6 It can be seen that the present invention can not only reproduce the technical solution according to the steps described in Embodiment 1, but also demonstrates the technical effects of improving the ability to reuse shared content, proving the necessity of dividing the four types of mirror content, reducing the average mirror deployment time, and improving the hit rate of the local content library of the node in the experimental results.
[0111] Example 3
[0112] This embodiment discloses a container image reuse optimization system based on content reconstruction, applied to the container image reuse optimization method based on content reconstruction disclosed in Embodiments 1 and 2 above. The system includes:
[0113] The parsing and recovery view module is used to parse each target image in the target image set and restore the final visible file view of each target image according to the image layer overlay semantics and deletion semantics;
[0114] The content set identification module is used to identify the shared content set and the unique content set by identifying the file content that appears repeatedly across target images based on the final visible file view of each target image.
[0115] The image content partitioning module is used to obtain the file content accessed by each target image during the container startup phase, form a startup access set, and divide the image content into startup shared content, startup unique content, delayed shared content, and delayed unique content based on the shared content set, unique content set, and startup access set.
[0116] The target image reconstruction module is used to reconstruct the target image according to the startup shared content, startup unique content, delayed shared content, and delayed unique content, generating a reconstructed image containing the startup content layer and the delayed content layer.
[0117] The container image deployment module is optimized. When deploying and reconstructing an image on a node, the startup content layer is acquired and assembled first to put the container into a ready state. After the container enters the ready state, the delayed content layer is acquired and assembled, and the existing shared content on the node is reused during the deployment process to complete the optimized deployment of container image reuse.
[0118] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0119] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.
Claims
1. A method for optimizing container image reuse based on content reconstruction, characterized in that, The container image reuse optimization method includes the following steps: S1. Parse each target image in the target image set and restore the final visible file view of each target image according to the image layer overlay semantics and deletion semantics; S2. Based on the final visible file view of each target image, identify the shared content of files that appear repeatedly across target images to obtain a set of shared content and a set of unique content. S3. Obtain the file content accessed by each target image during the container startup phase, form a startup access set, and divide the image content into startup shared content, startup unique content, delayed shared content, and delayed unique content based on the shared content set, unique content set, and startup access set. S4. Reconstruct the target image according to the startup shared content, startup unique content, delayed shared content, and delayed unique content to generate a reconstructed image containing the startup content layer and the delayed content layer. S5. When deploying a reconstructed image on a node, prioritize acquiring and assembling the startup content layer to bring the container into a ready state. After the container enters the ready state, continue to acquire and assemble the delayed content layer, and reuse the shared content already available on the node during the deployment process to complete the optimized deployment of container image reuse.
2. The container image reuse optimization method based on content reconstruction according to claim 1, characterized in that, In step S1, the process of restoring the final visible file view of each target image is as follows: S11. Read the file objects in each original image layer according to the arrangement order of the original image layers in the target image, and record the file path, file type and content summary of the file objects; S12. When the upper-level file object and the lower-level file object have the same file path, retain the upper-level file object and remove the lower-level file object. S13. When there are deletion marks in the original image layer, remove the deleted file objects or file objects in the masked directory according to the deletion marks to obtain the final visible file view of the target image.
3. The container image reuse optimization method based on content reconstruction according to claim 1, characterized in that, In step S2, the process of obtaining the shared content set and the unique content set is as follows: S21. Using the content summary corresponding to the file content as the basis for judgment, compare the file objects in the final visible file view of each target image; S22. File objects that appear in two or more target images and have the same content digest are identified as shared content, and the shared content is added to the shared content set; S23. Identify file objects that appear only in one target image as unique content, and add the unique content to the unique content set.
4. The container image reuse optimization method based on content reconstruction according to claim 1, characterized in that, In step S3, the process of obtaining the access set is as follows: S301. Start the container instance corresponding to the target image in a controlled environment; S302. From the moment the container starts up until the moment the application inside the container is ready to provide services to the outside world after initialization, record the contents of the files accessed during this time period. S303. The recorded file contents are combined into a boot access set for the target image.
5. The container image reuse optimization method based on content reconstruction according to claim 1, characterized in that, In step S3, the process of dividing the mirrored content into startup shared content, startup unique content, delayed shared content, and delayed unique content is as follows: S311. The content that belongs to both the shared content set and the startup access set is classified as startup shared content; S312. The content that belongs to both the unique content set and the startup access set is classified as startup unique content; S313. Content that belongs to the shared content set but does not belong to the initial access set is classified as delayed shared content; S314. Content that belongs to the unique content set but does not belong to the start access set is classified as delayed unique content.
6. The container image reuse optimization method based on content reconstruction according to claim 1, characterized in that, In step S4, the process of reconstructing the content of the target image is as follows: S41. Organize the shared startup content and the unique startup content into a startup content layer, and organize the delayed shared content and the delayed unique startup content into a delayed content layer. S42. Identify the same shared content in different target images using the same content digest, so that the same shared content can be reused in different target images; S43. Rewrite the image list according to the order in which the startup content layer is located before the delayed content layer to obtain the reconstructed image.
7. The container image reuse optimization method based on content reconstruction according to claim 1, characterized in that, In step S5, the process of deploying and reconstructing the image on the node is as follows: S501. After receiving the deployment request for the image to be deployed, the node parses the image list of the reconstructed image and processes the startup content layer first. S502. For shared startup content in the startup content layer, if content with the same content digest already exists in the node's local content library, the content in the node's local content library is directly reused; if content with the same content digest does not exist in the node's local content library, the corresponding content is obtained from the mirror repository and written to the node's local content library. S503. For startup-specific content in the startup content layer, write it to the dedicated directory of the current image to be deployed. S504. Assemble the startup content layer according to the mirror layer overlay semantics and deletion semantics, so that the container enters the ready state; S505. After the container enters the ready state, continue to acquire and assemble the deferred content layer.
8. The container image reuse optimization method based on content reconstruction according to claim 1, characterized in that, During the process of deploying and reconstructing the image on the node, the content objects in the node's local content library are cached and replaced. The process is as follows: S511. When the local storage capacity of a node is insufficient to write new content objects, exclude content objects that are being downloaded, verified, unpacked, assembled, or used by the deployment path before the container is ready. S512. Among the remaining content objects, determine the retention priority in ascending order of delayed unique content, delayed shared content, initiated unique content, and initiated shared content. S513. Prioritize selecting content objects to be evicted from content objects with lower retention priority, and within the same retention priority, select content objects to be evicted based on the access time and the number of repeated accesses. S514. If no content object can be evicted, the new content object is only used temporarily for the purposes of this deployment and is not written to the node's local content library.
9. A container image reuse optimization system based on content reconstruction, characterized in that, A container image reuse optimization method based on content reconstruction, applicable to any one of claims 1-8, wherein the system comprises: The parsing and recovery view module is used to parse each target image in the target image set and restore the final visible file view of each target image according to the image layer overlay semantics and deletion semantics; The content set identification module is used to identify the shared content set and the unique content set by identifying the file content that appears repeatedly across target images based on the final visible file view of each target image. The image content partitioning module is used to obtain the file content accessed by each target image during the container startup phase, form a startup access set, and divide the image content into startup shared content, startup unique content, delayed shared content, and delayed unique content based on the shared content set, unique content set, and startup access set. The target image reconstruction module is used to reconstruct the target image according to the startup shared content, startup unique content, delayed shared content, and delayed unique content, generating a reconstructed image containing the startup content layer and the delayed content layer. The container image deployment module is optimized. When deploying and reconstructing an image on a node, the startup content layer is acquired and assembled first to put the container into a ready state. After the container enters the ready state, the delayed content layer is acquired and assembled, and the existing shared content on the node is reused during the deployment process to complete the optimized deployment of container image reuse.
10. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory that is communicatively connected to at least one processor; wherein, The memory stores computer program instructions that can be executed by at least one processor, such that the at least one processor can perform a content-based container image reuse optimization method as described in any one of claims 1-8.