A method and apparatus for replicating an image

By repackaging and encrypting image files in a cloud computing environment, the problems of time-consuming image copying and security risks are solved, and an efficient and secure image copying process is achieved.

CN115129425BActive Publication Date: 2026-04-14JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
Filing Date
2022-07-11
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In the cloud computing ecosystem, the image copying process is time-consuming, consumes file system storage resources, and poses security risks.

Method used

The process involves creating a top-level directory on the server, downloading the image layer information form file and layer files, compressing and encrypting them to generate an image compressed file, and returning it to the terminal; and then decrypting and decompressing the image layer information and layer files in the destination image repository before uploading them.

Benefits of technology

It improves image copying efficiency, saves storage resources and operation time, enhances security, avoids the decompression operation of image layer files, and does not depend on Docker tools.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115129425B_ABST
    Figure CN115129425B_ABST
Patent Text Reader

Abstract

The application discloses a method and device for copying an image, and relates to the technical field of cloud computing. A specific embodiment of the method comprises the following steps: receiving an image file downloading request sent by a terminal, wherein the image file downloading request carries an image name; creating a first directory according to the image name, downloading an image layer information table file and each layer file from a source image warehouse, and storing the image layer information table file and the each layer file under the first directory; compressing and encrypting the first directory to obtain an image compressed file; and returning the image compressed file to the terminal. The embodiment can solve the technical problems of time consumption, occupation of file system resources and security risks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of cloud computing technology, and in particular to a method and apparatus for copying images. Background Technology

[0002] Currently, the delivery method in the cloud computing ecosystem is image-based. An image packages an application and its runtime environment, enabling a build-once, run-everywhere, and run any application. Images have a unified central storage repository called an image repository, and different environments may have different image repositories. When copying an image from one environment's image repository to an isolated environment's image repository, the two image repositories are not interconnected, and logging into the isolated environment typically requires network tools such as VPNs.

[0003] In the process of realizing this invention, the inventors discovered that the prior art has at least the following problems: it is time-consuming, occupies file system storage resources, and poses security risks. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a method and apparatus for copying images to solve the technical problems of being time-consuming, consuming file system storage resources, and posing security risks.

[0005] To achieve the above objectives, according to one aspect of the present invention, a method for copying an image is provided, applied to a first server, comprising:

[0006] The receiving terminal sends a download request for an image file, the download request carrying the image name;

[0007] Create a first-level directory based on the image name, download the image layer information form file and each layer file from the source image repository, and store the image layer information form file and each layer file in the first-level directory;

[0008] The first-level directory is compressed and encrypted to obtain a compressed image file;

[0009] The image compression file is returned to the terminal.

[0010] Optionally, downloading the image layer information form file and each layer file from the source image repository, and storing the image layer information form file and each layer file in the first-level directory, includes:

[0011] The image layer information form file is obtained from the source image repository according to the image name, and the image layer information form file is written to the first-level directory;

[0012] Extract the hash value of each layer file from the image layer information form file, and download each layer file sequentially from the source image repository according to the hash value of each layer file;

[0013] Based on the hash value of each layer file, create corresponding second-level directories under the first-level directory, and store each layer file in the corresponding second-level directory.

[0014] Optionally, the layer files include layer files for configuration files and layer files for mirror layers.

[0015] Optionally, the hash value is a SHA256 value.

[0016] Optionally, based on the hash values ​​of each layer of files, corresponding second-level directories are created under the first-level directory, and each layer of files is stored in its corresponding second-level directory, including:

[0017] For each layer file, create a second-level directory under the first-level directory based on the hash value of the layer file;

[0018] Store the layer files in the second-level directory.

[0019] Furthermore, according to another aspect of the present invention, a method for replicating an image is provided, applied to a second server, comprising:

[0020] The receiving terminal sends an image file upload request, which carries an image compressed file and an image name;

[0021] The image compressed file is decrypted and decompressed to obtain an image layer information form file and individual layer files;

[0022] Create an image in the destination image repository based on the image name carried in the image file upload request;

[0023] Upload the image layer information form file and each layer file in the unzipped directory to the image name of the destination image repository.

[0024] Optionally, the image layer information form file and each layer file in the unzipped directory are uploaded to the image name of the destination image repository, including:

[0025] Retrieve the image layer information form file in the unzipped directory;

[0026] Extract the hash values ​​of each layer file from the image layer information form file;

[0027] Based on the hash values ​​of each layer file, upload each layer file in the decompressed directory to the image name of the destination image repository;

[0028] Upload the image layer information form file to the image name of the destination image repository.

[0029] Optionally, based on the hash values ​​of each layer file, the layers in the decompressed directory are uploaded to the image name of the destination image repository, including:

[0030] For each layer file, the second-level directory is located in the decompression directory based on the hash value of the layer file, and the layer file in the second-level directory is uploaded to the image name of the destination image repository.

[0031] Optionally, the layer files include layer files for configuration files and layer files for mirror layers.

[0032] Optionally, the hash value is a SHA256 value.

[0033] Optionally, after uploading the image layer information form file and each layer file from the unzipped directory to the image name of the destination image repository, the method further includes:

[0034] Delete the image compression file, as well as the image layer information form file and each layer file in the decompressed directory.

[0035] Furthermore, according to another aspect of the present invention, an apparatus for copying an image is provided, disposed on a first server, comprising:

[0036] The first receiving module is used to receive a download request for an image file sent by the terminal, wherein the download request carries the image name;

[0037] The download module is used to create a first-level directory based on the image name, download the image layer information form file and each layer file from the source image repository, and store the image layer information form file and each layer file in the first-level directory.

[0038] The compression module is used to compress and encrypt the first-level directory to obtain a compressed image file;

[0039] The return module is used to return the image compressed file to the terminal.

[0040] Optionally, the download module is further configured to:

[0041] The image layer information form file is obtained from the source image repository according to the image name, and the image layer information form file is written to the first-level directory;

[0042] Extract the hash value of each layer file from the image layer information form file, and download each layer file sequentially from the source image repository according to the hash value of each layer file;

[0043] Based on the hash value of each layer file, create corresponding second-level directories under the first-level directory, and store each layer file in the corresponding second-level directory.

[0044] Optionally, the layer files include layer files for configuration files and layer files for mirror layers.

[0045] Optionally, the hash value is a SHA256 value.

[0046] Optionally, the download module is further configured to:

[0047] For each layer file, create a second-level directory under the first-level directory based on the hash value of the layer file;

[0048] Store the layer files in the second-level directory.

[0049] Furthermore, according to another aspect of the present invention, an apparatus for copying an image is provided, disposed on a second server, comprising:

[0050] The second receiving module is used to receive an image file upload request sent by the terminal, wherein the image file upload request carries an image compressed file and an image name;

[0051] The decompression module is used to decrypt and decompress the image compressed file to obtain the image layer information form file and the files of each layer;

[0052] A creation module is used to create an image in the destination image repository based on the image name carried in the image file upload request;

[0053] The upload module is used to upload the image layer information form file and the various layer files in the decompressed directory to the image name of the destination image repository.

[0054] Optionally, the upload module is further configured to:

[0055] Retrieve the image layer information form file in the unzipped directory;

[0056] Extract the hash values ​​of each layer file from the image layer information form file;

[0057] Based on the hash values ​​of each layer file, upload each layer file in the decompressed directory to the image name of the destination image repository;

[0058] Upload the image layer information form file to the image name of the destination image repository.

[0059] Optionally, the upload module is further configured to:

[0060] For each layer file, the second-level directory is located in the decompression directory based on the hash value of the layer file, and the layer file in the second-level directory is uploaded to the image name of the destination image repository.

[0061] Optionally, the layer files include layer files for configuration files and layer files for mirror layers.

[0062] Optionally, the hash value is a SHA256 value.

[0063] Optionally, a deletion module is also included for:

[0064] After uploading the image layer information form file and each layer file in the decompressed directory to the image name of the destination image repository, delete the image compressed file, as well as the image layer information form file and each layer file in the decompressed directory.

[0065] According to another aspect of the present invention, an electronic device is also provided, comprising:

[0066] One or more processors;

[0067] Storage device for storing one or more programs.

[0068] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.

[0069] According to another aspect of the present invention, a computer-readable medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the methods described in any of the above embodiments.

[0070] According to another aspect of the present invention, a computer program product is also provided, including a computer program that, when executed by a processor, implements the methods described in any of the above embodiments.

[0071] One embodiment of the above invention has the following advantages or beneficial effects: the embodiment of the invention ensures security by repackaging and encrypting the image file, and the user does not need to decompress the layer files of the image, keeping the source file unchanged; the entire process uses network packets, without the need for Docker tools; and it does not require loading the image into the local image storage system, saving compression time, synchronization time, and upload time, thereby improving copying efficiency, saving storage resources and operation time, and enhancing the effectiveness of image copying.

[0072] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description

[0073] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:

[0074] Figure 1 This is a schematic diagram of the main flow of a method for copying an image according to an embodiment of the present invention;

[0075] Figure 2 This is a schematic diagram of the main flow of a method for copying an image according to a possible embodiment of the present invention;

[0076] Figure 3 This is a schematic diagram of the main flow of a method for copying an image according to another embodiment of the present invention;

[0077] Figure 4 This is a schematic diagram of the main flow of a method for copying an image according to another applicable embodiment of the present invention;

[0078] Figure 5 This is a schematic diagram of the main modules of an apparatus for copying an image according to an embodiment of the present invention;

[0079] Figure 6 This is a schematic diagram of the main modules of an apparatus for copying an image according to another embodiment of the present invention;

[0080] Figure 7 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;

[0081] Figure 8 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation

[0082] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0083] Figure 1 This is a schematic diagram illustrating the main flow of a method for copying an image according to an embodiment of the present invention. As an embodiment of the present invention, such as... Figure 1 As shown, the method for replicating the image, applied to the first server, may include:

[0084] Step 101: Receive a download request for an image file sent by the terminal, wherein the download request carries the image name.

[0085] Users can send a download request for an image file to a first server via a terminal, simultaneously submitting the image file name, thus including the image file name in the download request. Upon receiving the download request, the first server parses it to obtain the image file name. A form page can be provided to the user, allowing them to select an image file name. In some embodiments of this invention, the first server may be a production environment server.

[0086] Step 102: Create a first-level directory based on the image name, download the image layer information form file and each layer file from the source image repository, and store the image layer information form file and each layer file in the first-level directory.

[0087] The first server creates a top-level directory based on the image name submitted by the user, then downloads the image layer information form file and each layer file from the source image repository, and stores the downloaded image layer information form file and each layer file in this directory. Optionally, the each layer file includes the layer file of the configuration file and the layer file of the image layer. Optionally, the hash value is a SHA256 value.

[0088] Optionally, the image layer information form file may be maniefst, which stores the image's metadata, mainly including: the storage location of the layer files of the configuration file, identified by sha256; and the storage location of the layer files of the image layer (in list form), identified by sha256.

[0089] Optionally, download the image layer information form file and each layer file from the source image repository, and store the image layer information form file and each layer file under the first-level directory, including: obtaining the image layer information form file from the source image repository according to the image name, and writing the image layer information form file under the first-level directory; extracting the hash values of each layer file from the image layer information form file, and sequentially downloading each layer file from the source image repository according to the hash values of each layer file; creating corresponding second-level directories under the first-level directory according to the hash values of each layer file, and storing each layer file in the corresponding second-level directory. Specifically, obtain the image layer information form file (manifest) of the image from the source image repository according to the image name submitted by the user, and write it into the first-level directory with the file name manifest.json. Then, extract the sha256 values of each layer file from the manifest, sequentially download each layer file from the source image repository according to the sha256 values of each layer file, and finally create corresponding second-level directories under the first-level directory according to the sha256 values of each layer file, and store each layer file in the corresponding second-level directory. Since the storage locations of each layer file are fixed, for example: blobs / sha256 / <the first two digits of the sha256> / <the sha256 value> / data, the actual storage locations of each layer file in the source image repository can be accurately located through the sha256 values recorded in the manifest.json.

[0090] Optionally, creating corresponding second-level directories under the first-level directory according to the hash values of each layer file, and storing each layer file in the corresponding second-level directory, includes: for each layer file, creating a second-level directory under the first-level directory according to the hash value of the layer file; storing the layer file in the second-level directory. Specifically, obtain the list of sha256 values from the image layer information form file. For each layer file, extract the sha256 value of the layer file from the list of sha256 values, then create a second-level directory according to the first 12 digits of the sha256 value, store the layer file in the second-level directory, and name the layer file layer_gzip.tar.

[0091] Therefore, the directory structure is as follows:

[0092] Image name

[0093] |-Form file: manifest.json

[0094] |-<The first 12 digits of the sha256 of the layer file of the configuration file>

[0095] |- Layer file for configuration files: layrer_gzip.tar

[0096] |-<First 12 bits of the SHA256 hash of the image layer file>

[0097] |- The layer file for the image layer: layer_gzip.tar

[0098] For example:

[0099] |--3c6f07b4ab9c

[0100] |`--layer_gzip.tar

[0101] |--f707f8cf77bd

[0102] |`--layer_gzip.tar

[0103] --manifest.json

[0104] It should be noted that a second-level directory can also be created based on the first 10 digits of the SHA256 value, the first 15 digits of the SHA256 value, or the first 8 digits of the SHA256 value. This embodiment of the invention does not limit this.

[0105] It should be noted that, in the embodiments of the present invention, the first-level directory and the second-level directory are not absolute directories, but relative directories. The first-level directory is the parent directory of the second-level directory, and the second-level directory is the child directory of the first-level directory.

[0106] Step 103: Compress and encrypt the first-level directory to obtain a compressed image file;

[0107] The first-level directory is compressed and encrypted using a preset encryption algorithm to obtain a compressed image file.

[0108] Step 104: Return the image compression file to the terminal.

[0109] Finally, the generated image archive is returned to the terminal, and the user downloads it to their local machine. Since the first server has encrypted the image archive, the user cannot open it after downloading it, thus eliminating the security risk.

[0110] Based on the various embodiments described above, it can be seen that the embodiments of the present invention solve the technical problems of serious time consumption, resource consumption in the file system, and security risks in the prior art by having the server create a first-level directory based on the image name, download the image layer information form file and each layer file from the source image repository and store these files in the first-level directory, then compress and encrypt the first-level directory, and finally return the compressed image file to the terminal. The embodiments of the present invention ensure security by repackaging and encrypting the image file, and the user does not need to decompress the image layer files, keeping the source files unchanged; the entire process uses network packets, without the need for Docker tools; and it does not require loading the image into the local image storage system, saving compression time, synchronization time, and upload time, thereby improving copying efficiency, saving storage resources and operation time, and enhancing the effectiveness of image copying.

[0111] Figure 2 This is a schematic diagram illustrating the main flow of a method for copying an image according to a possible embodiment of the present invention. As another embodiment of the present invention, such as... Figure 2 As shown, the method for replicating the image, applied to the first server, may include:

[0112] Step 201: Receive a download request for an image file sent by the terminal, wherein the download request carries the image name.

[0113] Step 202: Create a first-level directory based on the image name.

[0114] Step 203: Obtain the image layer information form file (manifest) from the source image repository according to the image name, and write the image layer information form file to the first-level directory with the file name manifest.json.

[0115] Step 204: Extract the SHA256 values ​​of each layer file from the image layer information form file, and download each layer file sequentially from the source image repository based on the SHA256 values ​​of each layer file. The layer files include configuration file layer files and image layer layer files.

[0116] Step 205: Based on the SHA256 values ​​of each layer file, create corresponding second-level directories under the first-level directory, and store each layer file in the corresponding second-level directory.

[0117] Specifically, for each layer file, a second-level directory is created under the first-level directory based on the first 12 bits of the hash value of the layer file, and then the layer file is stored in the second-level directory and named layer_gzip.tar.

[0118] Step 206: Compress and encrypt the first-level directory to obtain a compressed image file.

[0119] Step 207: Return the image compression file to the terminal.

[0120] Furthermore, the specific implementation details of the method for copying an image in one of the reference embodiments of the present invention have been described in detail in the above-described method for copying an image, so the details will not be repeated here.

[0121] Figure 3 This is a schematic diagram of the main flow of a method for copying an image according to another embodiment of the present invention. As another embodiment of the present invention, such as... Figure 3 As shown, the method for replicating the image, applied to a second server, may include:

[0122] Step 301: Receive an image file upload request sent by the terminal, wherein the image file upload request carries an image compressed file and an image name.

[0123] After downloading the image compressed file to their local machine, the user continues to send an image file upload request to the second server via the terminal, submitting the image name at the same time. It should be noted that the image name in the image file download request can be the same as or different from the image file upload request.

[0124] The second server can be a server in an isolated environment. In the isolated environment, there is also a corresponding form page for users to enter the name of the image in the isolated environment. In the isolated environment, the image name may change and be different from the previously packaged image name.

[0125] Optionally, before step 301, the user logs into the isolated environment using a VPN or other network tool. After logging into the isolated environment, the user enters the name of the image in the isolated environment and uploads the image compressed file through a form page.

[0126] Step 302: Decrypt and decompress the image compressed file to obtain the image layer information form file and each layer file.

[0127] The second server decrypts and decompresses the image compressed file according to a preset decryption algorithm, thereby obtaining the image layer information form file manifest and individual layer files, wherein the individual layer files include configuration file layer files and image layer layer files. Optionally, the hash value is a SHA256 value.

[0128] It should be noted that the encryption algorithm of the first server and the decryption algorithm of the second server are corresponding and preset. Users cannot obtain the decryption algorithm, so they cannot decrypt and decompress the image compressed file, thus ensuring the security of the image file.

[0129] Step 303: Create an image in the destination image repository based on the image name carried in the image file upload request.

[0130] In this step, an image is created in the destination image repository based on the image name carried in the image file upload request. The destination image repository can be located in an isolated environment, and the second server stores the image name in the destination image repository to facilitate uploading files from the unzipped directory to the destination image repository.

[0131] Step 304: Upload the image layer information form file and each layer file in the unzipped directory to the image name of the destination image repository.

[0132] After creating the image name in the destination image repository, upload the image layer information form file and each layer file from the unzipped directory obtained in step 302 to the image name directory in the destination image repository, thus completing the process of uploading the image file to the destination image repository. After the above steps, the imported image can be viewed in the isolated environment.

[0133] Optionally, step 304 may include: obtaining the image layer information form file in the decompressed directory; extracting the hash values ​​of each layer file from the image layer information form file; uploading each layer file in the decompressed directory to the image name according to the hash values ​​of each layer file; and uploading the image layer information form file to the image name. In an embodiment of the present invention, firstly, the image layer information form file manifest in the decompressed directory is obtained. The manifest stores the image's metadata, mainly including: the storage location of the layer files of the configuration file, identified by SHA256; and the storage location (in list form) of the layer files of the image layer, identified by SHA256. Then, according to the SHA256 of each layer file, each layer file in the decompressed directory is uploaded to the image name in the destination image repository; after uploading each layer file, the image layer information form file manifest (e.g., manifest.json file) is uploaded to the image name in the destination image repository.

[0134] Optionally, based on the hash values ​​of each layer file, the layer files in the decompressed directory are uploaded to the image name. This includes: for each layer file, searching for the second-level directory in the decompressed directory based on the hash value of the layer file, and uploading the layer file in the second-level directory to the image name. Specifically, a list of SHA256 values ​​is obtained from the image layer information form file. For each layer file, the SHA256 value of the layer file is extracted from the SHA256 value list. Then, the first 12 digits of the SHA256 value are used as the second-level directory. The layer file (filenamed layer_gzip.tar) is searched in the second-level directory, and then the layer file is uploaded to the image name in the destination image repository.

[0135] Based on the various embodiments described above, it can be seen that the embodiments of the present invention solve the technical problems of serious time consumption, resource consumption in the file system, and security risks in the prior art by having the server decrypt and decompress the image compressed file, create an image name in the destination image repository according to the image name, and upload the image layer information form file and each layer file in the decompressed directory to the image name. The embodiments of the present invention ensure security by repackaging and encrypting the image file, and users do not need to decompress the image layer files, keeping the source files unchanged; the entire process uses network packets, without the need for Docker tools; and it does not require loading the image into the local image storage system, saving compression time, synchronization time, and upload time, thereby improving copying efficiency, saving storage resources and operation time, and enhancing the effectiveness of image copying.

[0136] Figure 4 This is a schematic diagram of the main flow of a method for copying an image according to another possible embodiment of the present invention. As another embodiment of the present invention, such as... Figure 4 As shown, the method for replicating the image, applied to a second server, may include:

[0137] Step 401: Receive an image file upload request sent by the terminal, wherein the image file upload request carries an image compressed file and an image name.

[0138] Step 402: Decrypt and decompress the image compressed file to obtain the image layer information manifest file and individual layer files. The individual layer files include configuration file layer files and image layer layer files.

[0139] Step 403: Create an image in the destination image repository based on the image name carried in the image file upload request.

[0140] Step 404: Obtain the image layer information form in the unzipped directory, named manifest.json.

[0141] Step 405: Extract the SHA256 values ​​of each layer file from the image layer information form file.

[0142] Step 406: Based on the SHA256 values ​​of each layer file, upload each layer file in the decompressed directory to the image name of the destination image repository.

[0143] Specifically, for each layer file, the first 12 bits of the SHA256 value of the layer file are used as a second-level directory. The second-level directory is located in the decompression directory, and the layer file (named layer_gzip.tar) in the second-level directory is uploaded to the image name.

[0144] Step 407: Upload the image layer information form file to the image name of the destination image repository.

[0145] Step 408: Delete the image compressed file, the image layer information form file and each layer file in the decompressed directory.

[0146] In addition, the specific implementation details of the method for copying an image in another reference embodiment of the present invention have been described in detail in the above-described method for copying an image, so the details will not be repeated here.

[0147] Figure 5 This is a schematic diagram of the main modules of an apparatus for copying an image according to an embodiment of the present invention. Figure 5 As shown, the image copying device 500 is located on a first server and includes a first receiving module 501, a download module 502, a compression module 503, and a return module 504. The first receiving module 501 receives an image file download request sent by a terminal, the download request carrying the image name. The download module 502 creates a first-level directory based on the image name, downloads the image layer information form file and each layer file from the source image repository, and stores the image layer information form file and each layer file in the first-level directory. The compression module 503 compresses and encrypts the first-level directory to obtain a compressed image file. The return module 504 returns the compressed image file to the terminal.

[0148] Optionally, the download module 502 is further configured to:

[0149] The image layer information form file is obtained from the source image repository according to the image name, and the image layer information form file is written to the first-level directory;

[0150] Extract the hash value of each layer file from the image layer information form file, and download each layer file sequentially from the source image repository according to the hash value of each layer file;

[0151] Based on the hash value of each layer file, create corresponding second-level directories under the first-level directory, and store each layer file in the corresponding second-level directory.

[0152] Optionally, the layer files include layer files for configuration files and layer files for image layers. Optionally, the hash value is a SHA256 value.

[0153] Optionally, the download module 502 is further configured to:

[0154] For each layer file, create a second-level directory under the first-level directory based on the hash value of the layer file;

[0155] Store the layer files in the second-level directory.

[0156] It should be noted that the specific implementation of the image copying device described in this invention has been described in detail in the image copying method described above, so the content will not be repeated here.

[0157] Figure 6 This is a schematic diagram of the main modules of an apparatus for copying an image according to another embodiment of the present invention. Figure 6 As shown, the image copying device 600 is located on a second server and includes a second receiving module 601, a decompression module 602, a creation module 603, and an upload module 604. The second receiving module 601 receives an image file upload request sent by a terminal, the request carrying an image compressed file and an image name. The decompression module 602 decrypts and decompresses the image compressed file to obtain an image layer information form file and individual layer files. The creation module 603 creates an image name in the destination image repository based on the image name carried in the image file upload request. The upload module 604 uploads the image layer information form file and individual layer files from the decompressed directory to the image name in the destination image repository.

[0158] Optionally, the upload module 604 is further configured to:

[0159] Retrieve the image layer information form file in the unzipped directory;

[0160] Extract the hash values ​​of each layer file from the image layer information form file;

[0161] Based on the hash values ​​of each layer file, upload each layer file in the decompressed directory to the image name of the destination image repository;

[0162] Upload the image layer information form file to the image name of the destination image repository.

[0163] Optionally, the upload module 604 is further configured to:

[0164] For each layer file, the first few digits of the hash value of the layer file are used as a second-level directory. The second-level directory is searched in the decompression directory, and the layer file in the second-level directory is uploaded to the image name.

[0165] Optionally, the layer files include layer files for configuration files and layer files for image layers. Optionally, the hash value is a SHA256 value.

[0166] Optionally, a deletion module is also included for:

[0167] After uploading the image layer information form file and each layer file in the decompressed directory to the image name of the destination image repository, delete the image compressed file, as well as the image layer information form file and each layer file in the decompressed directory.

[0168] It should be noted that the specific implementation of the image copying device described in this invention has been described in detail in the image copying method described above, so the content will not be repeated here.

[0169] Figure 7 An exemplary system architecture 700 is shown, in which the method or apparatus for copying an image can be applied according to embodiments of the present invention.

[0170] like Figure 7 As shown, system architecture 700 may include terminal devices 701, 702, and 703, a network 704, and a server 705. Network 704 serves as the medium for providing communication links between terminal devices 701, 702, and 703 and server 705. Network 704 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0171] Users can use terminal devices 701, 702, and 703 to interact with server 705 via network 704 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 701, 702, and 703, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).

[0172] Terminal devices 701, 702, and 703 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0173] Server 705 can be a server that provides various services, such as a backend management server that supports shopping websites browsed by users using terminal devices 701, 702, and 703 (this is just an example). The backend management server can analyze and process data such as received item information query requests, and then feed the processing results back to the terminal devices.

[0174] It should be noted that the image copying method provided in this embodiment of the invention is generally executed by server 705, and correspondingly, the image copying device is generally located in server 705.

[0175] It should be understood that Figure 7 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0176] The following is for reference. Figure 8 It shows a schematic diagram of the structure of a computer system 800 suitable for implementing a terminal device of the present invention. Figure 8 The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0177] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 802 or programs loaded from storage section 808 into random access memory (RAM) 803. The RAM 803 also stores various programs and data required for the operation of the system 800. The CPU 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0178] The following components are connected to I / O interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to I / O interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 810 as needed so that computer programs read from it can be installed into storage section 808 as needed.

[0179] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by central processing unit (CPU) 801, it performs the functions defined above in the system of this invention.

[0180] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0181] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer programs according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0182] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor can be described as including a first receiving module, a downloading module, a compression module, and a return module. The names of these modules do not necessarily limit the functionality of the module itself.

[0183] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor can be described as including a second receiving module, a decompression module, a creation module, and an upload module. The names of these modules do not necessarily limit the functionality of the module itself.

[0184] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device implements the following method: receiving an image file download request sent by a terminal, the image file download request carrying an image name; creating a first-level directory according to the image name; downloading an image layer information form file and each layer file from a source image repository, and storing the image layer information form file and each layer file in the first-level directory; compressing and encrypting the first-level directory to obtain a compressed image file; and returning the compressed image file to the terminal.

[0185] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device implements the following method: receiving an image file upload request sent by a terminal, the image file upload request carrying an image compressed file and an image name; decrypting and decompressing the image compressed file to obtain an image layer information form file and individual layer files; creating an image name in a destination image repository according to the image name; and uploading the image layer information form file and individual layer files from the decompressed directory to the image name.

[0186] In another aspect, embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the methods described in any of the above embodiments.

[0187] This invention ensures security by repackaging and encrypting the image file, and users do not need to decompress the image's layer files, keeping the source files unchanged; the entire process uses network packets, without the need for Docker tools; and there is no need to load the image into the local image storage system, saving compression time, synchronization time, and upload time, thereby improving copying efficiency, saving storage resources and operation time, and enhancing the effectiveness of image copying.

[0188] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for copying a mirror image, characterized in that, Applied to the first server, including: The receiving terminal sends a download request for an image file, the download request carrying the image name; Create a first-level directory based on the image name, download the image layer information form file and each layer file from the source image repository, and store the image layer information form file and each layer file in the first-level directory; The first-level directory is compressed and encrypted to obtain a compressed image file; The image compressed file is returned to the terminal, so that the terminal sends an image file upload request to the second server. The image file upload request carries the image compressed file and the image name; wherein the terminal cannot open the image compressed file.

2. The method according to claim 1, characterized in that, Download the image layer information form file and each layer file from the source image repository, and store the image layer information form file and each layer file in the first-level directory, including: The image layer information form file is obtained from the source image repository according to the image name, and the image layer information form file is written to the first-level directory; Extract the hash value of each layer file from the image layer information form file, and download each layer file sequentially from the source image repository according to the hash value of each layer file; Based on the hash value of each layer file, create corresponding second-level directories under the first-level directory, and store each layer file in the corresponding second-level directory.

3. The method according to claim 2, characterized in that, The layer files include the layer files for configuration files and the layer files for image layers.

4. The method according to claim 2, characterized in that, Based on the hash values ​​of each layer of files, corresponding second-level directories are created under the first-level directory, and each layer of files is stored in its corresponding second-level directory, including: For each layer file, create a second-level directory under the first-level directory based on the hash value of the layer file; Store the layer files in the second-level directory.

5. A method for copying a mirror image, characterized in that, Applied to the second server, including: The receiving terminal sends an image file upload request, which carries an image compressed file and an image name; the image compressed file is obtained by the first server using the following method: downloading the image layer information form file and each layer file from the source image repository, storing the image layer information form file and each layer file in a first-level directory, compressing and encrypting the first-level directory to obtain the image compressed file; wherein, the terminal cannot open the image compressed file; The image compressed file is decrypted and decompressed to obtain an image layer information form file and individual layer files; Create an image in the destination image repository based on the image name carried in the image file upload request; Upload the image layer information form file and each layer file in the unzipped directory to the image name of the destination image repository.

6. The method according to claim 5, characterized in that, Upload the image layer information form file and each layer file from the unzipped directory to the image name of the destination image repository, including: Retrieve the image layer information form file in the unzipped directory; Extract the hash values ​​of each layer file from the image layer information form file; Based on the hash values ​​of each layer file, upload each layer file in the decompressed directory to the image name of the destination image repository; Upload the image layer information form file to the image name of the destination image repository.

7. The method according to claim 6, characterized in that, Based on the hash values ​​of each layer file, upload each layer file in the decompressed directory to the image name of the destination image repository, including: For each layer file, the second-level directory is located in the decompression directory based on the hash value of the layer file, and the layer file in the second-level directory is uploaded to the image name of the destination image repository.

8. The method according to claim 6, characterized in that, The layer files include the layer files for configuration files and the layer files for image layers.

9. The method according to claim 5, characterized in that, After uploading the image layer information form file and each layer file from the unzipped directory to the image name of the destination image repository, the process also includes: Delete the image compression file, as well as the image layer information form file and each layer file in the decompressed directory.

10. An apparatus for copying an image, characterized in that, Configured on the first server, including: The first receiving module is used to receive a download request for an image file sent by the terminal, wherein the download request carries the image name; The download module is used to create a first-level directory based on the image name, download the image layer information form file and each layer file from the source image repository, and store the image layer information form file and each layer file in the first-level directory. The compression module is used to compress and encrypt the first-level directory to obtain a compressed image file; The return module is used to return the image compressed file to the terminal, so that the terminal can send an image file upload request to the second server. The image file upload request carries the image compressed file and the image name; wherein the terminal cannot open the image compressed file.

11. An apparatus for copying an image, characterized in that, Configured on the second server, including: The second receiving module is used to receive an image file upload request sent by the terminal. The image file upload request carries an image compressed file and an image name. The image compressed file is obtained by the first server using the following method: downloading the image layer information form file and each layer file from the source image repository, storing the image layer information form file and each layer file in a first-level directory, compressing and encrypting the first-level directory to obtain the image compressed file. The terminal cannot open the image compressed file. The decompression module is used to decrypt and decompress the image compressed file to obtain the image layer information form file and the files of each layer; A creation module is used to create an image in the destination image repository based on the image name carried in the image file upload request; The upload module is used to upload the image layer information form file and the various layer files in the decompressed directory to the image name of the destination image repository.

12. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-9.

13. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-9.

14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-9.

Citation Information

Patent Citations

  • Distributed storage based Docker image downloading method

    CN106506587A

  • Docker technology-based software product deployment method and system

    CN112181587A

  • Mirror image distribution method and device, terminal equipment and storage medium

    CN112671871A

  • Algorithm mirror image package uploading method, device and application

    CN113918096A