An OCI image incremental update method, device, medium, equipment and product
Patent Information
- Application Number
- CN202611061219.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-16
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]在现有技术中,镜像层通常是不可拆分的整体单元,当某一镜像层中的文件发生变化时,即使仅修改了该镜像层中的少量文件,也会导致该镜像层的内容发生变化,使得该镜像层难以继续复用原有版本中的对应镜像层
[0006]本实施例,通过生成增量变更镜像层并仅对目标依赖镜像层进行重构,使目标依赖镜像层之前的镜像层能够继续复用,减少了镜像层重复构建开销,提升了OCI镜像版本更新效率。
Smart Images

Figure CN123011291A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud computing technology, and in particular to an OCI (Open Container Initiative) image incremental update method, apparatus, medium, device and product. Background Technology
[0002] With the development of cloud computing and containerized deployment, container images have been widely used in application delivery, service deployment, and other scenarios. As an important standard in containerized deployment, the OCI image specification typically uses a layered structure to organize image data. Specifically, the file system content in an image is usually divided into multiple image layers, and different image layers are stacked sequentially to form the complete file system required for container runtime.
[0003] In existing technologies, image layers are typically indivisible units. When files within an image layer change, even modifying only a few files, the entire image layer's content changes, making it difficult to reuse the corresponding image layer from the previous version. Subsequent image layers are usually built upon the file system formed by preceding image layers. When a preceding image layer changes, the foundation for subsequent image layers may change, causing their build cache to become invalid. For images containing a large number of files, this mechanism incurs significant overhead from repeated builds, thus impacting image version update efficiency. Summary of the Invention
[0004] The purpose of this invention is to provide an incremental update method, apparatus, medium, device, and product for OCI images. It generates an incremental change image layer based on a changed image layer in a baseline version of the OCI image, determines a target dependent image layer that depends on the changed image layer, reconstructs the target dependent image layer, and then generates a target version of the OCI image based on the image layer preceding the target dependent image layer, the incremental change image layer, and the reconstructed target image layer set. This reduces the overhead of repeated builds caused by file changes within the changed image layer and improves the version update efficiency of the OCI image.
[0005] To achieve the above objectives, a first aspect of the present invention provides an incremental update method for an OCI image, the method comprising: Based on the changed image layer in the baseline version of the OCI image, generate the corresponding incremental changed image layer; The image layer that depends on the changed image layer is identified as the target dependent image layer; The target dependent image layer is reconstructed to generate a target reconstructed image layer set; A target version OCI image is generated based on the image layer preceding the target dependency image layer, the incremental change image layer, and the target reconstruction image layer set.
[0006] In this embodiment, by generating incremental change image layers and reconstructing only the target dependent image layers, the image layers before the target dependent image layers can continue to be reused, reducing the overhead of repeated image layer construction and improving the efficiency of OCI image version updates.
[0007] Furthermore, the process of generating a corresponding incremental change image layer based on the change image layer in the baseline version of the OCI image includes: Based on the differences between the file to be updated and the corresponding file in the baseline OCI image, determine the file change content and the corresponding changed image layer; Copy the target file data corresponding to the changes made to the file; An incremental change mirror layer is generated based on the target file data.
[0008] In this embodiment, by determining the file changes and their corresponding change mirror layers, and generating incremental change mirror layers based on the target file data, the redundant processing of unchanged files is reduced.
[0009] Further, the copying of the target file data corresponding to the changed file content includes: Determine the amount of change corresponding to the changes made to the document; If the amount of change is less than or equal to a preset threshold, then copy the changed file corresponding to the changed file content; If the amount of change is greater than the preset threshold, then all files corresponding to the changed image layer are copied.
[0010] In this embodiment, by selecting to copy the changed file or all files based on the comparison result between the amount of change and the preset threshold, an adaptation can be made between incremental copying and full copying, taking into account both update efficiency and the stability of mirror layer generation.
[0011] Further, determining the mirror layer that depends on the changed mirror layer as the target dependent mirror layer includes: Following the layer sequence order of the baseline version OCI image, candidate image layers are queried layer by layer, starting from the next image layer after the changed image layer; The first candidate image layer found that depends on the file changes in the changed image layer is determined as the target dependent image layer.
[0012] In this embodiment, by querying layer by layer after the change of the image layer, the first candidate image layer that depends on the changed file content is determined as the target dependent image layer, thereby reducing unnecessary image layer reconstruction.
[0013] Further, the mirror layer that depends on the changed mirror layer is determined through the following steps: Obtain the build instructions and / or file access information corresponding to the candidate image layer; Based on the build instructions and / or the file access information, analyze the inter-layer dependency relationship between the candidate image layer and the file change content corresponding to the changed image layer; If the inter-layer dependency relationship meets the preset dependency conditions, then the candidate mirror layer is determined as a mirror layer that depends on the changed mirror layer.
[0014] In this embodiment, by constructing instruction and / or file access information to analyze inter-layer dependencies, it is possible to accurately determine whether a candidate image layer depends on file changes, thereby improving the accuracy of determining the target dependent image layer.
[0015] Further, the reconstruction of the target dependent image layer to generate a target reconstructed image layer set includes: The target dependent image layer and the image layers following the target dependent image layer are reconstructed to generate a target reconstructed image layer set.
[0016] In this embodiment, by reconstructing the target dependent image layer and its subsequent image layers, the reconstructed image layers can form the correct layer sequence relationship based on incremental changes to the image layers, thus ensuring the consistency of the construction of the target version OCI image.
[0017] Furthermore, before generating the target version of the OCI image, the process also includes: Remove the layer reference information of the original image layer corresponding to the target reconstructed image layer set from the layer sequence of the target version OCI image to be generated.
[0018] In this embodiment, by deleting the layer reference information of the original image layer, the target version OCI image is prevented from continuing to reference the original image layer that has been reconstructed and replaced, thereby improving the accuracy of the target version OCI image layer sequence.
[0019] To achieve the above objectives, a second aspect of the present invention also provides an OCI image incremental update apparatus for implementing the OCI image incremental update method described in any of the first aspects, the apparatus comprising: The incremental change image layer generation module is used to generate corresponding incremental change image layers based on the change image layers in the baseline version OCI image. The target dependency image layer determination module is used to determine the image layer that depends on the changed image layer as the target dependency image layer; The target reconstruction image layer set generation module is used to reconstruct the target dependent image layers and generate a target reconstruction image layer set. The target version OCI image generation module is used to generate a target version OCI image based on the image layer located before the target dependent image layer, the incremental change image layer, and the target reconstruction image layer set.
[0020] Furthermore, the incremental change mirror layer generation module includes: The first incremental change image layer generation unit is used to determine the file change content and the change image layer corresponding to the file change content based on the difference between the file to be updated and the corresponding file in the baseline version OCI image. The second incremental change mirror layer generation unit is used to copy the target file data corresponding to the file change content; The third incremental change mirror layer generation unit is used to generate the incremental change mirror layer of the change mirror layer based on the target file data.
[0021] Furthermore, the target-dependent mirror layer determination module includes: The first target-dependent image layer determination unit is used to query candidate image layers one by one, starting from the next image layer of the changed image layer, according to the layer sequence order of the base version OCI image. The second target dependency mirror layer determination unit is used to determine the first candidate mirror layer that depends on the file change content in the changed mirror layer as the target dependency mirror layer.
[0022] Furthermore, the target reconstructed mirror layer set generation module includes: The target reconstruction image layer set generation unit is used to reconstruct the target dependent image layer and the image layer located after the target dependent image layer to generate a target reconstruction image layer set.
[0023] Furthermore, the device also includes: The layer reference information deletion module is used to delete the layer reference information of the original image layer corresponding to the target reconstructed image layer set from the layer sequence of the target version OCI image to be generated.
[0024] A third aspect of the present invention also provides a computer-readable storage medium, the computer-readable storage medium including a stored computer program; wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform an OCI image incremental update method as described in any of the first aspects above.
[0025] A fourth aspect of the present invention also provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements an OCI image incremental update method as described in any of the first aspects above.
[0026] The fifth aspect of the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements an OCI image incremental update method as described in any of the first aspects above. Attached Figure Description
[0027] Figure 1 This is a flowchart of a preferred embodiment of an OCI image incremental update method provided in the first aspect of the present invention; Figure 2 This is a schematic diagram illustrating the target version OCI image generation principle of another preferred embodiment of the OCI image incremental update method provided in the first aspect of the present invention; Figure 3 This is a schematic diagram of OCI image construction, representing another preferred embodiment of the OCI image incremental update method provided in the first aspect of the present invention. Figure 4 This is a diagram of an OCI image construction module, representing another preferred embodiment of an OCI image incremental update method provided in the first aspect of the present invention. Figure 5 This is a structural block diagram of a preferred embodiment of an OCI image incremental update device provided in the second aspect of the present invention; Figure 6 This is a structural block diagram of a preferred embodiment of a terminal device provided in the fourth aspect of the present invention. Detailed Implementation
[0028] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0029] It should be noted that the data involved in this invention (including but not limited to data used for analysis, data stored, data displayed, etc.) are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of related data must comply with relevant laws, regulations and standards, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0030] In this embodiment of the invention, the words "exemplarily" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplarily" or "for example" in this invention should not be construed as being more preferred or advantageous than other embodiments or designs. Rather, the use of the words "exemplarily" or "for example" is intended to present the relevant concepts in a specific manner.
[0031] In this invention description, the terms "first," "second," "third," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first," "second," "third," etc., may explicitly or implicitly include one or more of that feature. In this invention description, unless otherwise stated, "a plurality of" means two or more. In this invention description, the term "comprising" and its variations are open-ended, meaning "including but not limited to." The term "based on" means "at least partially based on." The term "according to" means "at least partially according to." The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments."
[0032] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0033] In the description of this invention, it should be noted that, unless otherwise defined, all technical and scientific terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in this specification is for the purpose of describing specific embodiments only and is not intended to limit the invention. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0034] The technical solution of the present invention will be further described below with reference to specific embodiments: The first aspect of this invention provides a method for incremental update of an OCI image, see [link to relevant documentation]. Figure 1 The diagram shown is a flowchart of a preferred embodiment of an OCI image incremental update method provided in the first aspect of the present invention. The method includes steps S1 to S4, as follows: Step S1: Generate the corresponding incremental change image layer based on the change image layer in the baseline version OCI image; The baseline OCI image can be a historical version image corresponding to the OCI image to be updated, or any reusable version image already existing in an image repository, local cache, or build cache. The baseline OCI image comprises multiple image layers stacked in a layer sequence, with each image layer used to collectively form the file system required for container operation.
[0035] The change image layer can be a base version OCI image layer that corresponds to the file to be updated, and whose content, attributes, path, deletion status, or other descriptive information has changed. The incremental change image layer can be a new image layer generated based on the file changes corresponding to the change image layer. File changes can include one or more of the following: adding a file, modifying a file, deleting a file, changing file permissions, changing file ownership, changing file path, and changing directory structure.
[0036] In one example, when the third image layer of the base version OCI image contains a large number of files, and the target version OCI image only modifies some of the files in the third image layer, it is not necessary to regenerate the complete third image layer. Instead, an incremental change image layer corresponding to the third image layer can be generated based on the modified files.
[0037] Step S2: Determine the mirror layer that depends on the changed mirror layer as the target dependent mirror layer; Specifically, after identifying the changed image layer, dependency analysis can be performed on the image layers following the changed image layer according to the layer sequence of the base version OCI image to determine whether there are any image layers that depend on the changed image layer. The target dependent image layer can be an image layer that needs to be built or executed based on the file changes corresponding to the changed image layer in subsequent image layers.
[0038] In this context, "dependent on the changed image layer" can be understood as meaning that the construction process, construction result, or file system overlay result of the candidate image layer is related to the file changes corresponding to the changed image layer. For example, the construction instructions corresponding to the candidate image layer read, reference, modify, delete, or overwrite the file path corresponding to the file changes, or the construction result of the candidate image layer needs to be determined based on the file changes.
[0039] In one alternative implementation, candidate mirror layers can be queried layer by layer according to the layer sequence, starting from the next mirror layer after the changed mirror layer; if the first candidate mirror layer that depends on the file changes in the changed mirror layer is found, then the candidate mirror layer is determined as the target dependent mirror layer.
[0040] It should be noted that the target dependency image layer can be the first dependency image layer found in the layer sequence. When multiple subsequent image layers depend on the changed image layer, the dependency image layer that appears first in the layer sequence can be determined as the target dependency image layer to maximize the reuse of image layers that precede the target dependency image layer.
[0041] Step S3: Reconstruct the target dependent image layer to generate a target reconstructed image layer set; Specifically, after determining the target dependent image layer, the target dependent image layer can be reconstructed based on the incrementally changed image layer to generate a corresponding target reconstructed image layer. Since the image layers following the target dependent image layer are usually built on the file system formed by the target dependent image layer, in an optional implementation, the target dependent image layer and the image layers following the target dependent image layer can be reconstructed to generate a set of target reconstructed image layers.
[0042] The target reconstructed image layer set may include one or more reconstructed image layers. When there are no other image layers after the target dependent image layer, the target reconstructed image layer set may only include the reconstructed image layer corresponding to the target dependent image layer; when there are other image layers after the target dependent image layer, the target reconstructed image layer set may include the reconstructed image layer corresponding to the target dependent image layer and the reconstructed image layer corresponding to subsequent image layers.
[0043] In one example, if the base version OCI image includes the first to tenth image layers, the third image layer is a modified image layer, the fourth to ninth image layers do not depend on the file changes corresponding to the third image layer, and the tenth image layer depends on the file changes corresponding to the third image layer, then the tenth image layer can be identified as the target dependent image layer, and the tenth image layer can be reconstructed based on the incremental modified image layer to generate the target reconstructed image layer corresponding to the tenth image layer.
[0044] In another example, if both the fifth and tenth mirror layers depend on the file changes corresponding to the third mirror layer, then the fifth mirror layer, which is first queried in the layer sequence, can be identified as the target dependent mirror layer. Based on the incremental changes to the mirror layer, the fifth mirror layer and its subsequent mirror layers can be reconstructed to generate the corresponding target reconstructed mirror layer set.
[0045] Step S4: Generate a target version OCI image based on the image layer preceding the target dependent image layer, the incremental change image layer, and the target reconstructed image layer set; Specifically, after generating the incremental change image layer and the target reconstruction image layer set, the image layer located before the target dependency image layer can be used as a reusable image layer, and the target version OCI image can be generated based on the reusable image layer, the incremental change image layer and the target reconstruction image layer set.
[0046] The image layer preceding the target dependent image layer may include one or more image layers in the base version OCI image between the starting image layer and the image layer preceding the target dependent image layer. The incremental change image layer may be located between the image layer preceding the target dependent image layer and the target reconstructed image layer set, so that the target reconstructed image layer set can be built and overlaid based on the file system state formed by the incremental change image layer.
[0047] In one alternative implementation, before generating the target version OCI image, the layer reference information of the original image layer corresponding to the target reconstructed image layer set in the base version OCI image can be deleted from the layer sequence of the target version OCI image to be generated, and the layer reference information of the incrementally changed image layer and the layer reference information of the target reconstructed image layer set can be written into the layer sequence of the target version OCI image to be generated.
[0048] In one example, the base version OCI image is V1.0, the target version OCI image is V1.1, some files in the third image layer have changed, and an incremental change image layer 3-1 is generated; if the tenth image layer is the target dependency image layer, then the target version OCI image may include the first to ninth image layers in V1.0, the incremental change image layer 3-1, and the target reconstructed image layer corresponding to the tenth image layer.
[0049] In this embodiment, an incremental change image layer is generated based on the change image layer in the base version OCI image, and the target dependency image layer is determined according to the inter-layer dependency relationship. Thus, only the target dependency image layer and related subsequent image layers are reconstructed, so that the image layers located before the target dependency image layer can continue to be reused, reducing the overhead of repeated image layer construction and repeated retrieval, and improving the efficiency of OCI image version update.
[0050] In another preferred embodiment, generating a corresponding incremental change image layer based on the change image layer in the baseline version OCI image includes: Based on the differences between the file to be updated and the corresponding file in the baseline OCI image, determine the file change content and the corresponding changed image layer; Copy the target file data corresponding to the changes made to the file; An incremental change mirror layer is generated based on the target file data.
[0051] The file to be updated can be a file in the build context corresponding to the target version of the OCI image to be built, and the corresponding file in the base version of the OCI image can be a file in the file system layer of the base version of the OCI image that has the same or corresponding storage path as the file to be updated. By comparing the differences between the file to be updated and the corresponding file in the base version of the OCI image, file changes such as added files, modified files, deleted files, and / or changes in file attributes can be determined, and the corresponding changed image layer can be determined based on the image layer where the file changes are located.
[0052] In one example, see Figure 2 The diagram shown illustrates the target version OCI image generation principle of another preferred embodiment of the OCI image incremental update method provided in the first aspect of this invention. The base version OCI image is image v1.0, which includes layers 1 to 10. Layer 3 in the Dockerfile corresponds to a file copy instruction, used to copy files from the large_scale_folder directory to the target_folder directory. If, during the construction of the target version OCI image, the files to be updated change relative to their corresponding files in the target_folder directory of image v1.0, then layer 3 can be identified as the changed image layer, and the changed file content in layer 3 can be identified as the difference content corresponding to the incrementally changed image layer to be generated.
[0053] Furthermore, the target file data corresponding to the file changes can be copied. This target file data may include the changed file data, as well as metadata describing file additions, modifications, deletions, or changes in file attributes. Based on this target file data, an incremental change mirror layer corresponding to layer 3 can be generated, for example... Figure 2 Layer 3-1 is shown in the diagram. Layer 3-1 is used to characterize the file changes in Layer 3 relative to the baseline version of the OCI image.
[0054] It should be noted that the file copying command is not limited to the Delay-Copy command, but can also be COPY, ADD or other build commands that can write file data to the mirror file system.
[0055] It should be noted that the difference comparison can be based on one or more of the following: file content, file summary, file path, file size, file modification time, file permissions, file owner information, or file metadata. This embodiment of the invention does not limit this.
[0056] In this embodiment, by determining the file change content and its corresponding change image layer based on the differences between the file to be updated and the corresponding file in the baseline OCI image, and generating an incremental change image layer based on the target file data corresponding to the file change content, the overhead of repeated copying and repeated building of unchanged files is reduced.
[0057] In yet another preferred embodiment, the copying of the target file data corresponding to the file changes includes: Determine the amount of change corresponding to the changes made to the document; If the amount of change is less than or equal to a preset threshold, then copy the changed file corresponding to the changed file content; If the amount of change is greater than the preset threshold, then all files corresponding to the changed image layer are copied.
[0058] The change quantity is used to characterize the degree of change of the file content relative to the changed mirror layer. The change quantity may include one or more of the following: the number of changed files, the total size of changed files, the percentage of changed files by number, and the percentage of changed file size.
[0059] The preset threshold can be pre-set based on image building requirements, image layer size, build efficiency requirements, or file copying strategy, or it can be dynamically determined based on historical build data or the current build environment.
[0060] In one example, when the change mirror layer corresponds to a file copying operation that copies a large-scale file directory to a target directory, if only a small number of files change, the amount of change is less than or equal to a preset threshold. In this case, only the changed files are copied, and an incremental change mirror layer is generated based on the changed files. If a large number of files change, the amount of change is greater than the preset threshold. In this case, all files corresponding to the change mirror layer are copied to avoid the processing overhead caused by copying too many scattered files.
[0061] It should be noted that the changed files may include the tag information corresponding to newly added files, modified files, deleted files, and files whose file attributes have changed.
[0062] Understandably, when the amount of change is small, copying only the changed files can reduce the amount of data copied; when the amount of change is large, copying all the files corresponding to the changed mirror layer can reduce the complexity of processing the difference files one by one, thereby improving the stability of the mirror layer generation process.
[0063] In this embodiment, by comparing the amount of change corresponding to the file change with a preset threshold, the system selects to copy the changed file or copy all files corresponding to the changed image layer. This allows for an adaptive selection between incremental copying and full copying, balancing image update efficiency and image layer generation stability.
[0064] In yet another preferred embodiment, determining the mirror layer that depends on the changed mirror layer as the target dependent mirror layer includes: Following the layer sequence order of the baseline version OCI image, candidate image layers are queried layer by layer, starting from the next image layer after the changed image layer; The first candidate image layer found that depends on the file changes in the changed image layer is determined as the target dependent image layer.
[0065] The candidate image layer is the image layer in the base version OCI image that follows the changed image layer. Searching for candidate image layers sequentially according to the layer sequence means starting from the image layer immediately following the changed image layer and determining whether each candidate image layer depends on the file changes in the changed image layer.
[0066] The phrase "dependent on the file changes in the modified image layer" can be understood as the candidate image layer needing to use, read, reference, or generate the build result based on the file changes during the build process. If a candidate image layer does not depend on the file changes, the search continues for the next candidate image layer until a candidate image layer that depends on the file changes is found, at which point that candidate image layer is determined as the target dependent image layer.
[0067] In one example, see Figure 3 The diagram shown is a schematic diagram of OCI image construction, representing another preferred embodiment of the OCI image incremental update method provided in the first aspect of the present invention. The base version OCI image is image V1.0, which includes layers 1 to 10. If layer 3 is a changed image layer, the query proceeds layer by layer from the next image layer after layer 3. Specifically, it first checks whether layer 4 depends on the changed file content in layer 3; if layer 4 does not depend on the changed file content in layer 3, it continues to query layer 5, and so on, until the first image layer that depends on the changed file content in layer 3 is found, and this image layer is identified as the target dependent image layer.
[0068] It should be noted that the target dependency image layer is the first dependency image layer found in the layer sequence, not any one or the last dependency image layer among all dependency image layers. By determining the first dependent image layer, the starting point for incremental changes to the image layer in the subsequent build process can be clearly identified.
[0069] It is understandable that an image layer located after the changed image layer and before the target dependent image layer can be used as a reusable image layer when generating the target version OCI image, since it does not depend on the file changes in the changed image layer.
[0070] In this embodiment, by following the layer sequence order of the baseline version OCI image, candidate image layers are queried layer by layer starting from the next image layer after the changed image layer, and the first candidate image layer that depends on the file changes in the changed image layer is determined as the target dependent image layer. This can accurately determine the position where the incremental changes start to affect subsequent image layers, reducing unnecessary image layer reconstruction.
[0071] In yet another preferred embodiment, the mirror layer that depends on the changed mirror layer is determined by the following steps: Obtain the build instructions and / or file access information corresponding to the candidate image layer; Based on the build instructions and / or the file access information, analyze the inter-layer dependency relationship between the candidate image layer and the file change content corresponding to the changed image layer; If the inter-layer dependency relationship meets the preset dependency conditions, then the candidate mirror layer is determined as a mirror layer that depends on the changed mirror layer.
[0072] The build instructions can be image build instructions used to generate the candidate image layer, including one or more of the following: file copy instructions, command execution instructions, file addition instructions, and directory operation instructions. The file access information can include the file read path, file write path, file deletion path, file reference path, and / or file overwrite path corresponding to the candidate image layer during the build process.
[0073] The inter-layer dependency relationship is used to characterize whether the construction process or result of the candidate image layer is affected by the file changes corresponding to the changed image layer. If the construction instructions or file access information corresponding to the candidate image layer point to the file path, directory path, or file metadata corresponding to the file changes, it can be determined that there is an inter-layer dependency relationship between the candidate image layer and the file changes corresponding to the changed image layer.
[0074] In one example, an image building tool can parse the Dockerfile or build graph to obtain the structured build instructions corresponding to each candidate image layer. It can also collect file access information corresponding to each candidate image layer during the image building process, and determine whether the candidate image layer depends on the file changes based on the structured build instructions and / or file access information.
[0075] It should be noted that the preset dependency conditions may include one or more of the following: path matching conditions, file reading conditions, file writing conditions, file deletion conditions, file overwriting conditions, and build instruction reference conditions. As long as the construction process or result of the candidate image layer requires determination based on the changes in the file content, the inter-layer dependency relationship can be considered to satisfy the preset dependency conditions.
[0076] It is understandable that when the build instructions alone cannot accurately determine whether a candidate image layer depends on the changed file content, file access information can be used for further judgment; when the build instructions can clearly define the dependency relationship between the candidate image layer and the changed file content, the judgment can also be made solely based on the build instructions.
[0077] In this embodiment, by obtaining the build instructions and / or file access information corresponding to the candidate image layer, and analyzing the inter-layer dependency relationship between the candidate image layer and the file change content corresponding to the changed image layer, it is possible to accurately determine whether the candidate image layer depends on the changed image layer, thereby improving the accuracy of determining the target dependent image layer and avoiding unnecessary reconstruction of image layers that are not affected by file change content.
[0078] In yet another preferred embodiment, the step of reconstructing the target dependent image layer to generate a target reconstructed image layer set includes: The target dependent image layer and the image layers following the target dependent image layer are reconstructed to generate a target reconstructed image layer set.
[0079] The image layer following the target dependent image layer refers to the image layer arranged after the target dependent image layer in the layer sequence of the base version OCI image. Since subsequent image layers are usually built on the file system formed by the preceding image layers, when the target dependent image layer is reconstructed, the image layers following the target dependent image layer can also be reconstructed to generate a target reconstructed image layer set.
[0080] In one example, see Figure 4 This diagram illustrates an OCI image construction module of another preferred embodiment of the OCI image incremental update method provided in the first aspect of the present invention. The baseline OCI image in the diagram is image V1.0, which includes layers 1 to 10. If layer 10 is determined to be the target dependent image layer, then layer 10 is reconstructed to generate a reconstructed layer 10', and layer 10' is used as the image layer in the target reconstructed image layer set. If other image layers exist after the target dependent image layer, then these other image layers are also reconstructed, and the reconstructed image layers are collectively used as the target reconstructed image layer set.
[0081] It should be noted that the target reconstructed image layer set may include one image layer or multiple image layers. When the target dependent image layer is the last image layer in the base version OCI image, the target reconstructed image layer set may only include the reconstructed image layer corresponding to the target dependent image layer; when there are subsequent image layers after the target dependent image layer, the target reconstructed image layer set may include the reconstructed image layers corresponding to the target dependent image layer and its subsequent image layers respectively.
[0082] In this embodiment, by reconstructing the target dependent image layer and the image layer located after the target dependent image layer, the image layer affected by the file changes can be regenerated based on the new build foundation, ensuring the correctness of the layer sequence relationship and file system overlay result of the target version OCI image.
[0083] In yet another preferred embodiment, before generating the target version OCI image, the method further includes: Remove the layer reference information of the original image layer corresponding to the target reconstructed image layer set from the layer sequence of the target version OCI image to be generated.
[0084] The layer reference information is used to represent the image layer referenced in the layer sequence of the target version OCI image. The layer reference information may include one or more of the following: image layer identifier, image layer summary, image layer storage address, and image layer order information.
[0085] The original image layer corresponding to the target reconstructed image layer set refers to the old version image layer corresponding to the reconstructed image layer in the base version OCI image. The target reconstructed image layer set is used to replace the original image layer in the generation of the layer sequence of the target version OCI image.
[0086] In one example, the base version OCI image is image V1.0, which includes layers 1 to 10. If layer 10 is determined to be the target dependent image layer and is reconstructed to obtain a new layer 10', then before generating the target version OCI image V1.1, the layer reference information of the original layer 10 in the base version OCI image V1.0 is deleted from the layer sequence of the target version OCI image V1.1 to be generated, so that the target version OCI image V1.1 no longer references the original layer 10.
[0087] In one example, if the target reconstructed image layer set includes reconstructed layers 5' to 10', then the layer reference information of the original layers 5 to 10 in the base version OCI image is removed from the layer sequence of the target version OCI image to be generated, so as to avoid the target version OCI image referencing both the original image layers and the corresponding reconstructed image layers at the same time.
[0088] It should be noted that deleting the layer reference information does not mean that the original image layer must be physically deleted from the image repository, local image cache, or layer storage space. Rather, it means that when generating the target version OCI image, the original image layer will no longer be used as a valid reference layer in the target version OCI image layer sequence.
[0089] It is understandable that after deleting the layer reference information of the original image layer, the target version OCI image to be generated can continue to reference the image layer located before the target dependent image layer, and replace the corresponding original image layer with the target reconstructed image layer set, thereby forming a new image layer sequence.
[0090] In this embodiment, by deleting the layer reference information of the original image layer corresponding to the target reconstructed image layer set from the layer sequence of the target version OCI image to be generated, the target version OCI image can avoid continuing to reference the original image layer that has been reconstructed and replaced, thus ensuring the accuracy of the target version OCI image layer sequence.
[0091] In yet another preferred embodiment, the OCI image incremental update method can be applied to image building systems based on Docker and BuildKit. See also Figure 4 The diagram shown is an OCI image building module diagram of another preferred embodiment of an OCI image incremental update method provided in the first aspect of the present invention. The image building system includes a client layer, a Docker daemon layer, a Docker engine layer, a BuildKit core building layer, a storage and driver layer, and a final container layer.
[0092] Specifically, at the client layer, users input image build commands through the user input module, such as `docker build -f Dockerfile`, to initiate a build request for the target version of the OCI image. After receiving the image build command, the Client (Docker client) performs basic parsing of the image build command and encapsulates it into a standardized build request conforming to the Docker API specification.
[0093] At the Docker daemon layer, the Docker Daemon receives standardized build requests from clients and hands them over to the Docker Server for processing. The Docker Server, acting as a server-side processing module, routes and distributes these standardized build requests, and then forwards the distributed build tasks to the Docker engine layer.
[0094] At the Docker engine layer, the Engine receives the build tasks and abstracts them into standardized build jobs. The Build Manager coordinates the lifecycle of the build jobs and calls the BuildKit core build layer to accelerate the build process. Job1~JobN (batch build tasks) take over the sub-build tasks output by the BuildKit core build layer and interact with the image repository, storage, and driver layers as needed.
[0095] In the BuildKit core build layer, Frontend (LLB) is used to convert the Dockerfile build definition into an LLB-formatted build DAG graph. The Parser parses the LLB-formatted build DAG graph to obtain structured build instructions. The Instruction Dispatcher distributes the structured build instructions to the corresponding processing units according to instruction type.
[0096] Furthermore, the Cache Manager manages the build cache and determines reusable image layers in the baseline version OCI image based on image layer summaries, content hashes, or cache records. The Solver solves the build DAG graph to obtain the basic dependencies between build steps. The Dependency Analyzer analyzes the inter-layer dependencies between build steps to determine whether candidate image layers depend on the file changes corresponding to the modified image layers.
[0097] The Scheduler is used to schedule build tasks based on the inter-layer dependencies and structured build instructions. The Scheduler integrates a delay layer calculation module and a file change difference module. The file change difference module determines the file change content and the corresponding changed image layer based on the differences between the file to be updated and the corresponding file in the baseline OCI image, and generates an incremental changed image layer based on the file change content. The delay layer calculation module queries candidate image layers layer by layer, starting from the next image layer of the changed image layer, according to the layer sequence of the baseline OCI image, and determines the candidate image layer that first depends on the changed image layer as the target dependent image layer.
[0098] The Execution Engine executes executable tasks scheduled by the Scheduler to generate the incremental change image layer and reconstructs the target dependency image layer and the image layers following it, generating a target reconstructed image layer set. Layer Storage stores the incremental change image layer and the target reconstructed image layer set, and provides image layer cache read and write support to the Cache Manager.
[0099] In the storage and driver layer, the image repository provides storage and distribution for base images, baseline OCI images, or historical image versions. The driver layer handles image storage, network configuration, and container execution based on the execution requirements of the build task. Specifically, the Graph Driver manages layered image storage and forms a container file system based on the image layer sequence in the target OCI image; the Network Driver configures the network environment for the container; and the Exec Driver calls system interfaces to start the container process and manages the container execution process.
[0100] At the final container layer, the Docker container starts a container instance based on the completed target version OCI image and the runtime environment obtained from the storage and driver layer initialization.
[0101] In one example, a user inputs the command `docker build -f Dockerfile` via the Client. DockerDaemon and Docker Server receive and distribute the build request. The Engine abstracts this build request into a build job, and the BuildManager calls the BuildKit core build layer for processing. The Frontend converts the Dockerfile into an LLB build DAG graph, the Parser parses it to obtain structured build instructions, the Instruction Dispatcher distributes the build instructions to the corresponding processing units, the Cache Manager reads the cache layer of the baseline version OCI image, and the Solver and Dependency Analyzer analyze the dependencies between build steps. The Scheduler determines the changed image layer and its corresponding incremental changed image layer based on the file change difference module, and determines the target dependent image layer based on the delay layer calculation module. The Execution Engine generates the incremental changed image layer and reconstructs the target dependent image layer and its subsequent image layers to obtain the target reconstructed image layer set. Layer Storage stores the generated image layers, and then generates the target version OCI image based on the reusable image layer, incremental changed image layer, and target reconstructed image layer set.
[0102] It should be noted that Frontend (LLB), Parser, Instruction Dispatcher, Cache Manager, Solver (DAG), Dependency Analyzer, Scheduler, Execution Engine, and Layer Storage in this embodiment are only one module division method in the BuildKit implementation. In other embodiments, the above functions can also be implemented by corresponding functional modules in other image builders, image packaging tools, or image update systems.
[0103] It should be noted that the Graph Driver, Network Driver, and Exec Driver are mainly used for the initialization of the container runtime environment after the target version OCI image is generated. They do not affect the determination process of incremental change image layers, target dependent image layers, and target reconstructed image layer sets.
[0104] Understandably, a mirror repository can be a remote OCI mirror repository, a local mirror repository, or a cache repository; Layer Storage can be local layer storage, cache storage, or image layer storage space associated with the mirror repository.
[0105] This embodiment combines modules such as Frontend, Parser, Instruction Dispatcher, Cache Manager, Solver, Dependency Analyzer, Scheduler, Execution Engine, and Layer Storage in the Docker and BuildKit build chain to achieve file change difference identification, inter-layer dependency analysis, incremental change image layer generation, and target dependency image layer reconstruction. This improves the efficiency of OCI image incremental updates while ensuring the correctness of the image build results.
[0106] A second aspect of the present invention provides an OCI image incremental update apparatus for implementing an OCI image incremental update method as described in any of the first aspects of the present invention. (See also...) Figure 5 The diagram shown is a structural block diagram of a preferred embodiment of an OCI image incremental update device provided in the second aspect of the present invention. The device includes: The incremental change image layer generation module 11 is used to generate a corresponding incremental change image layer based on the change image layer in the baseline version OCI image. The target dependency image layer determination module 12 is used to determine the image layer that depends on the changed image layer as the target dependency image layer; The target reconstruction image layer set generation module 13 is used to reconstruct the target dependent image layer and generate a target reconstruction image layer set. The target version OCI image generation module 14 is used to generate a target version OCI image based on the image layer located before the target dependent image layer, the incremental change image layer, and the target reconstruction image layer set.
[0107] Preferably, the incremental change mirror layer generation module includes: The first incremental change image layer generation unit is used to determine the file change content and the change image layer corresponding to the file change content based on the difference between the file to be updated and the corresponding file in the baseline version OCI image. The second incremental change mirror layer generation unit is used to copy the target file data corresponding to the file change content; The third incremental change mirror layer generation unit is used to generate the incremental change mirror layer of the change mirror layer based on the target file data.
[0108] Preferably, the target file data corresponding to the file changes is copied through the following steps: Determine the amount of change corresponding to the changes made to the document; If the amount of change is less than or equal to a preset threshold, then copy the changed file corresponding to the changed file content; If the amount of change is greater than the preset threshold, then all files corresponding to the changed image layer are copied.
[0109] Preferably, the target dependency image layer determination module includes: The first target-dependent image layer determination unit is used to query candidate image layers one by one, starting from the next image layer of the changed image layer, according to the layer sequence order of the base version OCI image. The second target dependency mirror layer determination unit is used to determine the first candidate mirror layer that depends on the file change content in the changed mirror layer as the target dependency mirror layer.
[0110] Preferably, the mirror layer that depends on the changed mirror layer is determined through the following steps: Obtain the build instructions and / or file access information corresponding to the candidate image layer; Based on the build instructions and / or the file access information, analyze the inter-layer dependency relationship between the candidate image layer and the file change content corresponding to the changed image layer; If the inter-layer dependency relationship meets the preset dependency conditions, then the candidate mirror layer is determined as a mirror layer that depends on the changed mirror layer.
[0111] Preferably, the target reconstructed mirror layer set generation module includes: The target reconstruction image layer set generation unit is used to reconstruct the target dependent image layer and the image layer located after the target dependent image layer to generate a target reconstruction image layer set.
[0112] Preferably, the apparatus further includes a layer reference information deletion module, used to delete the layer reference information of the original image layer corresponding to the target reconstructed image layer set in the base version OCI image from the layer sequence of the target version OCI image to be generated.
[0113] It should be noted that the OCI image incremental update device provided in the second aspect embodiment of the present invention can realize all the processes of the OCI image incremental update method described in the first aspect. The functions and technical effects of each module and unit in the device are the same as those of the OCI image incremental update method described in the first aspect embodiment, and will not be repeated here.
[0114] A third aspect of the present invention also provides a computer-readable storage medium, the computer-readable storage medium including a stored computer program; wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform an OCI image incremental update method as described in any of the first aspects of the present invention.
[0115] The fourth aspect of the present invention also provides a terminal device, see [link to documentation]. Figure 6 The diagram shown is a structural block diagram of a preferred embodiment of a terminal device provided in the fourth aspect of the present invention. The terminal device includes a processor 10, a memory 20, and a computer program stored in the memory 20 and configured to be executed by the processor 10. When the processor 10 executes the computer program, it implements an OCI image incremental update method as described in any of the above embodiments.
[0116] Preferably, the computer program can be divided into one or more modules / units (such as computer program 1, computer program 2, ...), and the one or more modules / units are stored in the memory 20 and executed by the processor 10 to complete the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.
[0117] The processor 10 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor 10 may be any conventional processor. The processor 10 is the control center of the terminal device, connecting various parts of the terminal device through various interfaces and lines.
[0118] The memory 20 mainly includes a program storage area and a data storage area. The program storage area can store the operating system, applications required for at least one function, etc., while the data storage area can store related data, etc. Furthermore, the memory 20 can be a high-speed random access memory, or a non-volatile memory, such as a plug-in hard drive, a smart media card (SMC), a secure digital card (SD), and a flash card, or other volatile solid-state storage devices.
[0119] It should be noted that the aforementioned terminal device may include, but is not limited to, processors and memory. Those skilled in the art will understand that the above content is merely an example describing the structure of the terminal device and does not constitute a limitation on the structure of the aforementioned terminal device. The aforementioned terminal device may include more or fewer components than those described above, or combine certain components, or different components.
[0120] A fifth aspect embodiment of the present invention also provides a computer program product, including a computer program that, when executed by a processor 10, implements an OCI image incremental update method as described in any of the first aspect embodiments above.
[0121] Through the above description of the embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus necessary hardware platforms, and of course, it can also be implemented entirely by hardware. Based on this understanding, all or part of the technical solution of the present invention that contributes to the background technology can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM (Read-Only Memory) / RAM (Random Access Memory), magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of the present invention.
[0122] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided in this application, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0123] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. An incremental update method for an OCI image, characterized in that, include: Based on the changed image layer in the baseline version of the OCI image, generate the corresponding incremental changed image layer; The image layer that depends on the changed image layer is identified as the target dependent image layer; The target dependent image layer is reconstructed to generate a target reconstructed image layer set; A target version OCI image is generated based on the image layer preceding the target dependency image layer, the incremental change image layer, and the target reconstruction image layer set.
2. The OCI image incremental update method as described in claim 1, characterized in that, The process of generating a corresponding incremental change image layer based on the change image layer in the baseline version OCI image includes: Based on the differences between the file to be updated and the corresponding file in the baseline OCI image, determine the file change content and the corresponding changed image layer; Copy the target file data corresponding to the changes made to the file; An incremental change mirror layer is generated based on the target file data.
3. The OCI image incremental update method as described in claim 2, characterized in that, The copying of the target file data corresponding to the changed content of the file includes: Determine the amount of change corresponding to the changes made to the document; If the amount of change is less than or equal to a preset threshold, then copy the changed file corresponding to the changed file content; If the amount of change is greater than the preset threshold, then all files corresponding to the changed image layer are copied.
4. The OCI image incremental update method as described in claim 1, characterized in that, The step of determining the mirror layer that depends on the changed mirror layer as the target dependent mirror layer includes: Following the layer sequence order of the baseline version OCI image, candidate image layers are queried layer by layer, starting from the next image layer after the changed image layer; The first candidate image layer found that depends on the file changes in the changed image layer is determined as the target dependent image layer.
5. The OCI image incremental update method as described in claim 4, wherein the image layer dependent on the changed image layer is determined through the following steps: Obtain the build instructions and / or file access information corresponding to the candidate image layer; Based on the build instructions and / or the file access information, analyze the inter-layer dependency relationship between the candidate image layer and the file change content corresponding to the changed image layer; If the inter-layer dependency relationship meets the preset dependency conditions, then the candidate mirror layer is determined as a mirror layer that depends on the changed mirror layer.
6. The OCI image incremental update method as described in claim 1, characterized in that, The process of reconstructing the target dependent image layer to generate a target reconstructed image layer set includes: The target dependent image layer and the image layers following the target dependent image layer are reconstructed to generate a target reconstructed image layer set.
7. The OCI image incremental update method as described in claim 1, characterized in that, Before generating the target version OCI image, the following is also included: Remove the layer reference information of the original image layer corresponding to the target reconstructed image layer set from the layer sequence of the target version OCI image to be generated.
8. An OCI image incremental update apparatus for implementing an OCI image incremental update method as described in any one of claims 1 to 7, the apparatus comprising: The incremental change image layer generation module is used to generate corresponding incremental change image layers based on the change image layers in the baseline version OCI image. The target dependency image layer determination module is used to determine the image layer that depends on the changed image layer as the target dependency image layer; The target reconstruction image layer set generation module is used to reconstruct the target dependent image layers and generate a target reconstruction image layer set. The target version OCI image generation module is used to generate a target version OCI image based on the image layer located before the target dependent image layer, the incremental change image layer, and the target reconstruction image layer set.
9. An OCI mirror incremental update device as described in claim 8, characterized in that, The incremental change mirror layer generation module includes: The first incremental change image layer generation unit is used to determine the file change content and the change image layer corresponding to the file change content based on the difference between the file to be updated and the corresponding file in the baseline version OCI image. The second incremental change mirror layer generation unit is used to copy the target file data corresponding to the file change content; The third incremental change mirror layer generation unit is used to generate the incremental change mirror layer of the change mirror layer based on the target file data.
10. An OCI mirror incremental update device as described in claim 8, characterized in that, The target dependency image layer determination module includes: The first target-dependent image layer determination unit is used to query candidate image layers one by one, starting from the next image layer of the changed image layer, according to the layer sequence order of the base version OCI image. The second target dependency mirror layer determination unit is used to determine the first candidate mirror layer that depends on the file change content in the changed mirror layer as the target dependency mirror layer.
11. The OCI mirror incremental update device as described in claim 8, characterized in that, The target reconstruction mirror layer set generation module includes: The target reconstruction image layer set generation unit is used to reconstruct the target dependent image layer and the image layer located after the target dependent image layer to generate a target reconstruction image layer set.
12. The OCI mirror incremental update device as described in claim 8, characterized in that, Also includes: The layer reference information deletion module is used to delete the layer reference information of the original image layer corresponding to the target reconstructed image layer set from the layer sequence of the target version OCI image to be generated.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program; wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform an OCI image incremental update method as described in any one of claims 1 to 7.
14. A terminal device, characterized in that, The system includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements an OCI image incremental update method as described in any one of claims 1 to 7.
15. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements an OCI image incremental update method as described in any one of claims 1 to 7.
