Container image processing method, apparatus, device, and medium
By writing the source image address into the comment field and generating a metadata management file during the container image export process, the problem of lost container image metadata information is solved, and automatic recovery of image metadata and automation and traceability of image deployment are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
- Filing Date
- 2026-06-03
- Publication Date
- 2026-07-24
Smart Images

Figure CN122450596A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of container image processing technology, and in particular to a container image processing method, apparatus, device and medium. Background Technology
[0002] In the field of containerization technology, a container image is an immutable, standardized software delivery package that encapsulates a complete application and its runtime dependencies (such as system libraries, environment configurations, and code). It serves as a static template for generating and running container instances. Reliable migration and delivery of container images are the cornerstone for ensuring the consistency and portability of cloud-native applications across environments (such as development, testing, and production).
[0003] Currently, the export and import of container images mainly rely on specific container image processing tools (such as the image transfer and processing tool Skopeo). These tools extract images from the source repository and package them into offline archive files, then transfer them to the target environment via physical media or network. Finally, the offline archive files are imported into the target image repository or the local runtime.
[0004] However, when exporting a container image using specific container image processing tools, it is impossible to export the container image's metadata information, which can easily lead to the loss of the container image's metadata information (such as image name, tags, etc.). Summary of the Invention
[0005] To address the aforementioned technical problems, this disclosure provides a container image processing method, apparatus, device, and medium.
[0006] The first aspect of this disclosure provides a container image processing method, including: Obtain the source image address corresponding to the container image to be exported. The source image address includes at least one of the following: repository name and tag information. The container image to be exported is exported based on the preset container image processing tool and the source image address, generating an image archive file, and the source image address is written into the comment field of the image archive file. Obtain the metadata information corresponding to the container image to be exported, and generate a metadata management file based on the metadata information, which includes the source image address.
[0007] A second aspect of this disclosure provides a container image processing apparatus, comprising: The information acquisition module is used to obtain the source image address corresponding to the container image to be exported. The source image address includes at least one of the following: repository name and tag information. The image export module is used to export the container image to be exported based on the preset container image processing tool and the source image address, generate an image archive file, and write the source image address into the comment field of the image archive file. The metadata management file generation module is used to obtain the metadata information corresponding to the container image to be exported, and generate a metadata management file based on the metadata information, which includes the source image address.
[0008] A third aspect of this disclosure provides an electronic device, including: processor; Memory, used to store executable instructions; The processor is used to read executable instructions from memory and execute the executable instructions to implement the container image processing method provided in the first aspect above.
[0009] A fourth aspect of this disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to implement the container image processing method provided in the first aspect.
[0010] A fifth aspect of this disclosure provides a computer program product comprising a computer program or instructions that, when executed by a processor, implement the container image processing method of the first aspect described above.
[0011] The technical solution provided in this disclosure has the following advantages compared with the prior art: The container image processing method, apparatus, device, and medium provided in this disclosure can obtain the source image address corresponding to the container image to be exported, wherein the source image address includes at least one of repository name and tag information. After obtaining the source image address, the container image to be exported is exported based on a preset container image processing tool and the source image address, generating an image archive file, and the source image address is written into the comment field corresponding to the image archive file. Metadata information corresponding to the container image to be exported is obtained, and a metadata management file is generated based on the metadata information, wherein the metadata information includes the source image address. Thus, during the container image export process, the source image address can be written into the comment field corresponding to the image archive file, and a metadata management file can be generated for independent storage of metadata information. This ensures that the metadata information of the container image is always bound to the image file itself during the export process, and achieves dual backup, solving the problem of metadata information loss during container image export. Attached Figure Description
[0012] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0013] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0014] Figure 1 This is a flowchart of a container image processing method provided in an embodiment of this disclosure; Figure 2 This is a flowchart of a mirror import method provided in an embodiment of this disclosure; Figure 3 This is a flowchart of another container image processing method provided in this disclosure embodiment; Figure 4 This is a schematic diagram of the structure of a container image processing device provided in an embodiment of this disclosure; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0015] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0016] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0017] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0018] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0019] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0020] Typically, the export and import of container images relies on specific container image processing tools (such as the image transfer and processing tool Skopeo). These tools extract images from the source repository and package them into offline archive files, then transfer them to the target environment via physical media or network. Finally, the offline archive files are imported into the target image repository or the local runtime.
[0021] However, when exporting container images using specific container image processing tools, the container image metadata information cannot be exported. This results in the easy loss of metadata information corresponding to the container image (such as image name, tags, etc.), and the inability to automatically and accurately restore the container image metadata information during subsequent container image import. To address this issue, this disclosure provides a container image processing method, which will be described below with reference to specific embodiments.
[0022] Figure 1 This is a flowchart of a container image processing method provided in an embodiment of the present disclosure. The method can be executed by a container image processing device, which can be implemented in software and / or hardware. The container image processing device can be configured in an electronic device, such as a server or terminal, wherein the terminal specifically includes a mobile phone, computer or tablet computer, etc.
[0023] like Figure 1 As shown, the container image processing method provided in this embodiment includes the following steps.
[0024] S110. Obtain the source image address corresponding to the container image to be exported.
[0025] In this embodiment of the disclosure, the source image address includes at least one of the repository name and tag information, and may also include the source repository address corresponding to the container image to be exported.
[0026] The tag information may include version identification information corresponding to the container image to be exported, as well as environment identification information, build information, etc., corresponding to the container image to be exported.
[0027] For example, the format of the source mirror address can be: registry / repo:tag. Here, registry represents the source repository address, repo represents the repository name, and tag represents tag information.
[0028] Specifically, the container image processing device can respond to the user's container image export command, parse the container image export command, and obtain the source image address corresponding to the container image to be exported.
[0029] S120. Based on the preset container image processing tool and the source image address, export the container image to be exported, generate an image archive file, and write the source image address into the corresponding comment field of the image archive file.
[0030] In this embodiment of the disclosure, the preset container image processing tool can be understood as a tool capable of importing and exporting container images. For example, the preset container image processing tool can be Skopeo, a powerful yet lightweight command-line tool specifically designed for secure and efficient copying, importing, exporting, and inspecting of container images between different storage locations without starting a full container runtime; it can also be other tools capable of importing and exporting container images, without limitation.
[0031] Specifically, after obtaining the source image address, the container image processing device calls a preset container image processing tool to parse the source image address, converting it into a transmission protocol format recognizable by the preset tool. The preset tool then exports the container image to be exported in the target format, generating an image archive file. Simultaneously, the source image address is written to the corresponding comment field in the image archive file. The target format can be the Open Container Initiative Image ArchiveFormat (OCI archive). The image archive file can be a compressed file format, such as .tar.
[0032] For example, the source image address can be written into the comment field of the corresponding image archive file, specifically: Injecting into index.json.annotations: org.opencontainers.image.ref.name.
[0033] Here, index.json.annotations is the corresponding annotation field in the image archive file; org.opencontainers.image.ref.name is the annotation field used to identify the source image address.
[0034] It should be noted that the specific implementation method of exporting the container image to be exported into the target format by the preset container image processing tool and generating the image archive file is similar to the existing implementation method of exporting container images based on the preset container image processing tool, and will not be described in detail here.
[0035] S130. Obtain the metadata information corresponding to the container image to be exported, and generate a metadata management file based on the metadata information.
[0036] In this embodiment of the disclosure, the metadata information may include the source image address, image export time, image processing tool information (such as information related to a preset container image processing tool), platform architecture information supported by the image, image archive file hash value, etc.
[0037] Specifically, after generating an image archive file, the container image processing device can parse the image archive file to obtain the metadata information corresponding to the container image to be exported, and then write the metadata information into a preset metadata file to generate a metadata management file.
[0038] In this embodiment, the source image address corresponding to the container image to be exported can be obtained, wherein the source image address includes at least one of repository name and tag information. After obtaining the source image address, the container image to be exported is exported based on a preset container image processing tool and the source image address, generating an image archive file, and the source image address is written into the comment field corresponding to the image archive file. The metadata information corresponding to the container image to be exported is obtained, and a metadata management file is generated based on the metadata information, wherein the metadata information includes the source image address. Thus, during the container image export process, the source image address can be written into the comment field corresponding to the image archive file, and a metadata management file can be generated for independent storage of metadata information. This ensures that the metadata information of the container image is always bound to the image file itself during the export process, and achieves dual backup, solving the problem of metadata information loss during container image export.
[0039] Based on the above embodiments of this disclosure, by writing the source image address into the comment field of the image archive file, the automatic recovery capability of the image address can be improved. At the same time, by generating a metadata management file, it is convenient for R&D personnel to manage the container images to be exported, and provides a strong basis and support for tracing the source of the images to be exported in the future.
[0040] In this embodiment of the disclosure, the container image processing device can perform the import operation corresponding to the container image to be exported based on the metadata management file after generating the metadata management file, thereby realizing the automatic and accurate restoration of the metadata information of the container image during the container image import process.
[0041] In this embodiment of the disclosure, after generating a metadata management file based on metadata information, the container image processing method may further include: in response to an import instruction for the container image to be exported, reading metadata information from the metadata management file, and performing an import operation on the image archive file based on a preset container image processing tool and the metadata information, thereby importing the image archive file into the target repository.
[0042] In this embodiment of the disclosure, the import command can be a user-input command for importing the container image to be exported into the target repository. The import command may specify information such as the repository address and name corresponding to the target repository.
[0043] The following will combine Figure 2 The import process is described in detail.
[0044] like Figure 2 As shown, metadata information is read from the metadata management file, and based on the preset container image processing tool and metadata information, the image archive file is imported into the target repository. Specifically, this may include the following steps: S210. If the metadata information verification is successful, read the first mirror address corresponding to the field representing the mirror address or the second mirror address corresponding to the field representing the snapshot of the annotation field from the metadata management file.
[0045] S220. Determine the repository name and tag information of the container image to be exported based on the first image address or the second image address.
[0046] In this embodiment of the disclosure, after obtaining the first image address or the second image address, the container image processing device can parse the first image address or the second image address to obtain the repository name and tag information of the container image to be exported.
[0047] S230. Generate a third mirror address based on the warehouse address, warehouse name and tag information corresponding to the target warehouse.
[0048] In this embodiment of the disclosure, the container image processing device can construct a third image address by constructing the image address based on the warehouse address, warehouse name and tag information corresponding to the target warehouse according to the preset image address generation rules.
[0049] S240. Based on the third image address and the preset container image processing tool, perform the import operation of the image archive file and import the image archive file into the target repository.
[0050] In this embodiment, after generating a third image address, the container image processing device can invoke a preset container image processing tool, which then performs an import operation on the image archive file based on the third image address, importing the image archive file into the target repository. The specific implementation method of the preset container image processing tool performing the import operation on the image archive file based on the third image address is similar to existing implementation methods for image import based on preset container image processing tools, and will not be described in detail here.
[0051] In this embodiment, the image address recorded during the container image export process can be used as the traceability identifier of the container image. This image address is directly obtained during container image import, ensuring strict consistency between the container image's identity and origin during the import process. This effectively avoids version errors that may occur due to manual identification and enables automatic and accurate recovery of container image metadata information during import. Simultaneously, based on a preset container image processing tool, the automatic recovery from image archive files to the target repository can be completed efficiently and reliably, greatly improving the automation level, accuracy, and traceability of large-scale container image deployment.
[0052] In this embodiment of the disclosure, generating a metadata management file based on metadata information may specifically include: extracting each target metadata from the metadata information, writing each target metadata into at least one target field included in a preset metadata file, and generating a metadata management file.
[0053] In this embodiment of the disclosure, the target metadata corresponds one-to-one with the target field.
[0054] At least one target field includes a field representing the image address, a field representing the image export time, a field representing the image processing tool information, a field representing the platform architecture information supported by the image, a field representing the image archive file hash value, and a field representing the annotation field snapshot.
[0055] For example, the structure of a metadata management file can be as follows: { "source_image":"registry / repo:tag", "export_time":"2026-01-09T10:22:11Z", "tool":"skopeo 1.15", "platforms":["linux / amd64","linux / arm64"], "archive_sha256":"xxxx", "annotations_snapshot":{ "org.opencontainers.image.ref.name":"registry / repo:tag" } } Among them, source_image is a field representing the image address; export_time is a field representing the image export time; tool is a field representing the image processing tool information; platforms is a field representing the platform architecture information supported by the image; archive_sha256 is a field representing the hash value of the image archive file; and annotations_snapshot is a field representing the snapshot of the annotation field.
[0056] In this embodiment, each target metadata element is written into its corresponding target field in a preset metadata file to form a metadata management file. This achieves standardized encapsulation and fine-grained decoupling of container image metadata. It not only resolves the parsing ambiguity and compatibility risks caused by mixed metadata storage, enabling tools from different systems and stages to perform automated reading and processing based on a unified field standard, but also provides a fine-grained operational foundation for metadata retrieval, filtering, correlation analysis, and access control, supporting on-demand querying of specific metadata information. This provides standardized data support for large-scale image lifecycle management and cross-platform migration.
[0057] In this embodiment of the disclosure, the container image processing device can verify the metadata information in the metadata management file after generating the metadata management file, so as to ensure the accuracy and validity of the metadata information.
[0058] Specifically, before performing the import operation of the image archive file based on the preset container image processing tool and metadata information, the container image processing method may further include: obtaining a first comparison result between the source image address and a first image address corresponding to the field representing the image address in the metadata management file, and a second image address corresponding to the field representing the snapshot annotation field in the metadata management file; determining the target hash value corresponding to the image archive file, and obtaining a second comparison result between the target hash value and the image hash value corresponding to the field representing the hash value of the image archive file in the metadata management file; obtaining the first platform architecture information corresponding to the container image to be exported, and obtaining the field corresponding to the first platform architecture information and the field representing the platform architecture information supported by the image in the metadata management file. The metadata information verification is determined to be successful if the first comparison result indicates that the source image address is consistent with both the first and second image addresses, the second comparison result indicates that the target hash value is consistent with the image hash value, and the third comparison result indicates that the first platform architecture information is consistent with the second platform architecture information; or, if the first comparison result indicates that the source image address is inconsistent with the first image address, and / or the first comparison result indicates that the source image address is inconsistent with the second image address, and / or the second comparison result indicates that the target hash value is inconsistent with the image hash value, and / or the third comparison result indicates that the first platform architecture information is inconsistent with the second platform architecture information.
[0059] In some examples, the source mirror address is address A, and both the first and second mirror addresses are address A. This means that all fields in the source mirror address, the first mirror address, and the second mirror address are identical. If the target hash value corresponding to the image archive file is 'a', and the image hash value is also 'a', then the target hash value and the image hash value are identical. If the first platform architecture information includes linux / amd64 and linux / arm64, and the second platform architecture information also includes linux / amd64 and linux / arm64, then the first platform architecture information and the second platform architecture information are identical.
[0060] In other examples, the source mirror address is address A, and the first mirror address is address B. This means that some or all fields in the source mirror address and the first mirror address are inconsistent. Alternatively, if the first mirror address is empty, it indicates that the source mirror address and the first mirror address are inconsistent. Furthermore, the specific method for determining that the source mirror address and the second mirror address are inconsistent is similar to the method for determining that the source mirror address and the first mirror address are inconsistent, and will not be elaborated here. If the target hash value corresponding to the image archive file is 'a', and the image hash value is 'b', it indicates that the target hash value and the image hash value are inconsistent. If the first platform architecture information includes linux / amd64 and linux / arm64, and the second platform architecture information includes linux / amd64, or the second platform architecture information includes linux / amd32 and linux / arm64, this means that some or all of the first platform architecture information and the second platform architecture information are different. Alternatively, if the second platform architecture information does not completely cover the first platform architecture information, it indicates that the first platform architecture information and the second platform architecture information are inconsistent.
[0061] In this embodiment of the disclosure, the container image can support multiple platform architectures. For example, the platform architecture information supported by the image may include linux / amd64, linux / arm64, etc.
[0062] In this embodiment, the accuracy of the image address is ensured by verifying the image address and source image address in the metadata management file; the consistency and integrity of the image archive file are guaranteed by verifying the hash value of the image archive file; and the integrity of the image architecture is ensured by verifying the platform architecture information supported by the image. This enables advance verification of the integrity, consistency, and compliance of metadata information, allowing for the early detection of data corruption, tampering, or entry errors, preventing abnormal data from flowing into subsequent production deployment stages without requiring repeated scanning or manual review. This significantly improves the efficiency and accuracy of the entire image import process.
[0063] In this embodiment of the disclosure, the container image processing device can execute an intelligent inference mechanism to construct an image address in the event of metadata verification failure, and then perform an import operation of the image archive file based on the constructed image address.
[0064] The following will combine Figure 3 The specific implementation methods for container image processing are described.
[0065] like Figure 3 As shown, this container image processing method may specifically include the following steps: S310. Obtain the source image address corresponding to the container image to be exported.
[0066] S320. Based on the preset container image processing tool and the source image address, export the container image to be exported, generate an image archive file, and write the source image address into the corresponding comment field of the image archive file.
[0067] S330. Obtain the metadata information corresponding to the container image to be exported, and generate a metadata management file based on the metadata information.
[0068] It should be noted that the specific implementation of steps S310-S330 is similar to the specific implementation of steps S110-S130 in the above embodiments of this disclosure, and will not be repeated here.
[0069] S340. In the event that the metadata information verification fails, in response to the import instruction for the container image to be exported, construct a fourth image address based on the file name corresponding to the image archive file.
[0070] In this embodiment of the disclosure, constructing a fourth mirror address based on the file name corresponding to the mirror archive file may specifically include: removing the file extension corresponding to the file name to obtain the file name body; and determining the file name body as the fourth mirror address.
[0071] In this embodiment of the disclosure, the file name body includes the target repository name and target tag information.
[0072] S350: Based on the fourth image address and the preset container image processing tool, perform the import operation of the image archive file.
[0073] In this embodiment, the specific implementation of the image archive file import operation based on the fourth image address and the preset container image processing tool is similar to the existing implementation of image import based on the preset container image processing tool, and will not be described in detail here.
[0074] In this embodiment, even if metadata verification fails, the image address can be constructed based on the information in the file name of the image archive file, thereby enabling the image import operation. This achieves autonomous recovery and intelligent inference of the image address in scenarios where metadata verification fails. It avoids interruptions to the entire import process due to the failure of a single data source (such as a comment field or metadata management file), significantly improving the execution efficiency of large-scale image import scenarios and enhancing the system's fault tolerance.
[0075] Figure 4 This is a schematic diagram of the structure of a container image processing device provided in an embodiment of this disclosure.
[0076] In this embodiment of the disclosure, the container image processing device can be disposed within an electronic device and is understood as a part of the functional module of the aforementioned electronic device. Specifically, the electronic device can be a server or a terminal, wherein the terminal specifically includes mobile phones, computers, or tablet computers, etc., and is not limited thereto.
[0077] like Figure 4 As shown, the container image processing device 400 may include an information acquisition module 410, an image export module 420, and a metadata management file generation module 430.
[0078] The information acquisition module 410 can be used to acquire the source image address corresponding to the container image to be exported. The source image address includes at least one of the repository name and tag information. The image export module 420 can be used to export the container image to be exported based on the preset container image processing tool and the source image address, generate an image archive file, and write the source image address into the comment field corresponding to the image archive file; The metadata management file generation module 430 can be used to obtain the metadata information corresponding to the container image to be exported, and generate a metadata management file based on the metadata information, which includes the source image address.
[0079] In this embodiment, the source image address corresponding to the container image to be exported can be obtained, wherein the source image address includes at least one of repository name and tag information. After obtaining the source image address, the container image to be exported is exported based on a preset container image processing tool and the source image address, generating an image archive file, and the source image address is written into the comment field corresponding to the image archive file. The metadata information corresponding to the container image to be exported is obtained, and a metadata management file is generated based on the metadata information, wherein the metadata information includes the source image address. Thus, during the container image export process, the source image address can be written into the comment field corresponding to the image archive file, and a metadata management file can be generated for independent storage of metadata information. This ensures that the metadata information of the container image is always bound to the image file itself during the export process, and achieves dual backup, solving the problem of metadata information loss during container image export.
[0080] In some embodiments of this disclosure, the container image processing apparatus 400 may further include an image import module.
[0081] The image import module can be used to read metadata information from the metadata management file after generating a metadata management file based on metadata information, in response to the import command for the container image to be exported, and perform the import operation of the image archive file based on the preset container image processing tool and metadata information, so as to import the image archive file into the target repository.
[0082] In some embodiments of this disclosure, the metadata management file generation module 430 can be specifically used to extract each target metadata from the metadata information, write each target metadata into at least one target field included in a preset metadata file, and generate a metadata management file; the target metadata corresponds one-to-one with the target field; at least one target field includes a field representing the image address, a field representing the image export time, a field representing the image processing tool information, a field representing the platform architecture information supported by the image, a field representing the hash value of the image archive file, and a field representing the snapshot of the annotation field.
[0083] In some embodiments of this disclosure, the container image processing apparatus 400 may further include an information verification module.
[0084] The information verification module can be used to obtain the first comparison results between the source image address and the first image address corresponding to the field representing the image address in the metadata management file and the second image address corresponding to the field representing the snapshot of the comment field before performing the import operation of the image archive file based on the preset container image processing tool and metadata information; Determine the target hash value corresponding to the image archive file, and obtain the second comparison result between the target hash value and the image hash value corresponding to the field representing the hash value of the image archive file in the metadata management file; Obtain the first platform architecture information corresponding to the container image to be exported, and obtain the third comparison result between the first platform architecture information and the second platform architecture information corresponding to the field representing the platform architecture information supported by the image in the metadata management file; If the first comparison result indicates that the source image address matches both the first and second image addresses, the second comparison result indicates that the target hash value matches the image hash value, and the third comparison result indicates that the first platform architecture information matches the second platform architecture information, then the metadata information verification is deemed successful; or... If the first comparison result indicates that the source image address is inconsistent with the first image address, and / or the first comparison result indicates that the source image address is inconsistent with the second image address, and / or the second comparison result indicates that the target hash value is inconsistent with the image hash value, and / or the third comparison result indicates that the first platform architecture information is inconsistent with the second platform architecture information, then the metadata information verification is determined to have failed.
[0085] In some embodiments of this disclosure, the image import module can be specifically used to read the first image address corresponding to the field representing the image address or the second image address corresponding to the field representing the snapshot of the annotation field from the metadata management file when the metadata information verification is passed. The repository name and tag information of the container image to be exported are determined based on the first or second image address; A third mirror address is generated based on the warehouse address, warehouse name, and tag information corresponding to the target warehouse; Based on the third image address and the preset container image processing tool, the image archive file is imported into the target repository.
[0086] In some embodiments of this disclosure, the container image processing apparatus 400 may further include an intelligent inference module.
[0087] The intelligent inference module can be used to construct a fourth image address based on the file name corresponding to the image archive file after generating a metadata management file based on metadata information and in the event of a failure to verify the metadata information, in response to the import command for the container image to be exported. The image archive file is imported based on the fourth image address and the preset container image processing tool.
[0088] In some embodiments of this disclosure, the intelligent inference module can be specifically used to remove the file extension corresponding to the file name to obtain the file name body, which includes the target repository name and target tag information; The file name body is set to the fourth mirror address.
[0089] It should be noted that, Figure 4 The container image processing device 400 shown can execute the various steps in the above method embodiments and achieve the various processes and effects in the above method embodiments, which will not be elaborated here.
[0090] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure.
[0091] In this embodiment of the disclosure, Figure 5 The electronic devices shown can be servers or terminals, and terminals specifically include mobile phones, computers, or tablets, etc., without limitation.
[0092] like Figure 5 As shown, the electronic device may include a processor 510 and a memory 520 storing computer program instructions.
[0093] Specifically, the processor 510 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this disclosure.
[0094] Memory 520 may include a large-capacity storage device for information or instructions. For example, and not limitingly, memory 520 may include a hard disk drive (HDD), a floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 520 may include removable or non-removable (or fixed) media. Where appropriate, memory 520 may be internal or external to the integrated gateway device. In a particular embodiment, memory 520 is a non-volatile solid-state memory. In a particular embodiment, memory 520 includes read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (Electrically Programmable ROM, EPROM), an electrically erasable programmable PROM (EEPROM), an electrically alterable ROM (EAROM), or flash memory, or a combination of two or more of these.
[0095] The processor 510 reads and executes computer program instructions stored in the memory 520 to perform the steps of the container image processing method provided in this embodiment of the disclosure.
[0096] In one example, the electronic device may also include a transceiver 530 and a bus 540. Wherein, as... Figure 5 As shown, the processor 510, memory 520 and transceiver 530 are connected via bus 540 and communicate with each other.
[0097] Bus 540 may include hardware, software, or both. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industrial Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Where appropriate, bus 540 may include one or more buses.
[0098] This disclosure also provides a computer-readable storage medium that can store a computer program, which, when executed by a processor, causes the processor to implement the container image processing method provided in this disclosure.
[0099] The aforementioned storage medium may include, for example, a memory 520 containing computer program instructions, which can be executed by a processor 510 of an electronic device to complete the container image processing method provided in this embodiment. Optionally, the storage medium may be a non-transitory computer-readable storage medium, such as a ROM, random access memory (RAM), compact disc ROM (CD-ROM), magnetic tape, floppy disk, and optical data storage device.
[0100] This disclosure also provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a processor, they implement the container image processing method provided in this disclosure and can achieve the various processes and effects in the above embodiments of this disclosure, which will not be elaborated here.
[0101] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A container image processing method, characterized in that, The method includes: Obtain the source image address corresponding to the container image to be exported, wherein the source image address includes at least one of the repository name and tag information; The container image to be exported is exported based on the preset container image processing tool and the source image address, generating an image archive file, and the source image address is written into the comment field corresponding to the image archive file; Obtain the metadata information corresponding to the container image to be exported, and generate a metadata management file based on the metadata information, wherein the metadata information includes the source image address.
2. The method according to claim 1, characterized in that, After generating the metadata management file based on the metadata information, the method further includes: In response to the import command for the container image to be exported, the metadata information is read from the metadata management file, and the import operation of the image archive file is performed based on the preset container image processing tool and the metadata information, so as to import the image archive file into the target repository.
3. The method according to claim 1, characterized in that, The generation of metadata management files based on the metadata information includes: Extract each target metadata from the metadata information, and write each target metadata into at least one target field included in a preset metadata file to generate the metadata management file; the target metadata corresponds one-to-one with the target field; the at least one target field includes a field representing the image address, a field representing the image export time, a field representing the image processing tool information, a field representing the platform architecture information supported by the image, a field representing the hash value of the image archive file, and a field representing the snapshot of the comment field.
4. The method according to claim 2, characterized in that, Before performing the import operation of the image archive file based on the preset container image processing tool and the metadata information, the method further includes: Obtain the first comparison results between the source mirror address and the first mirror address corresponding to the field representing the mirror address in the metadata management file, and the second mirror address corresponding to the field representing the snapshot of the annotation field; Determine the target hash value corresponding to the image archive file, and obtain a second comparison result between the target hash value and the image hash value corresponding to the field representing the hash value of the image archive file in the metadata management file; Obtain the first platform architecture information corresponding to the container image to be exported, and obtain the third comparison result between the first platform architecture information and the second platform architecture information corresponding to the field representing the platform architecture information supported by the image in the metadata management file; If the first comparison result indicates that the source mirror address is consistent with both the first mirror address and the second mirror address, the second comparison result indicates that the target hash value is consistent with the mirror hash value, and the third comparison result indicates that the first platform architecture information is consistent with the second platform architecture information, then the metadata information verification is deemed successful; or... If the first comparison result indicates that the source mirror address is inconsistent with the first mirror address, and / or the first comparison result indicates that the source mirror address is inconsistent with the second mirror address, and / or the second comparison result indicates that the target hash value is inconsistent with the mirror hash value, and / or the third comparison result indicates that the first platform architecture information is inconsistent with the second platform architecture information, then the metadata information verification is determined to have failed.
5. The method according to claim 2, characterized in that, The step of reading the metadata information from the metadata management file and, based on the preset container image processing tool and the metadata information, performing an import operation on the image archive file to import the image archive file into the target repository includes: If the metadata information is verified, the first mirror address corresponding to the field representing the mirror address or the second mirror address corresponding to the field representing the snapshot of the annotation field is read from the metadata management file. The repository name and tag information of the container image to be exported are determined based on the first image address or the second image address; A third mirror address is generated based on the warehouse address corresponding to the target warehouse, the warehouse name, and the tag information; Based on the third image address and the preset container image processing tool, the image archive file is imported into the target repository.
6. The method according to claim 1, characterized in that, After generating the metadata management file based on the metadata information, the method further includes: If the metadata verification fails, in response to the import instruction for the container image to be exported, a fourth image address is constructed based on the file name corresponding to the image archive file. The image archive file is imported based on the fourth image address and the preset container image processing tool.
7. The method according to claim 6, characterized in that, The construction of the fourth mirror address based on the filename corresponding to the mirror archive file includes: Remove the file extension corresponding to the file name to obtain the file name body, which includes the target repository name and target tag information; The file name body is determined as the fourth mirror address.
8. A container image processing apparatus, characterized in that, include: The information acquisition module is used to acquire the source image address corresponding to the container image to be exported, wherein the source image address includes at least one of the repository name and tag information; The image export module is used to export the container image to be exported based on a preset container image processing tool and the source image address, generate an image archive file, and write the source image address into the comment field corresponding to the image archive file; The metadata management file generation module is used to obtain the metadata information corresponding to the container image to be exported, and generate a metadata management file based on the metadata information, wherein the metadata information includes the source image address.
9. An electronic device, characterized in that, include: processor; Memory, used to store executable instructions; The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the container image processing method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, causes the processor to implement the container image processing method according to any one of claims 1-7.