A method, system, device and storage medium for updating a Docker image

By extracting and merging images in layers, a difference layer file is generated and uploaded to a private cloud server, which solves the problem of cumbersome image updates in private servers and enables agile and lightweight image updates.

CN116301990BActive Publication Date: 2025-11-25CHINA ASEAN INFORMATION PORT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310273786.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-20
Publication Date
2025-11-25
Estimated Expiration
2043-03-20

AI Technical Summary

Technical Problem

In private servers, existing technologies require uploading large image tar packages for image updates, making the update process cumbersome. There is an urgent need for a more agile and lightweight update method.

Method used

By extracting and merging layers from the image, differential layer files are generated and uploaded to a private cloud server. The resulting images are then merged to create new images, requiring only a very small layer package for updates.

Benefits of technology

It achieves agility and convenience in the mirror update process on private servers, avoids uploading large file mirrors, and improves update efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116301990B_ABST
    Figure CN116301990B_ABST
Patent Text Reader

Abstract

The application discloses a kind of Docker image update method, system, equipment and storage medium, belong to software application technical field, method is: S1. Docker image A, Docker image B are obtained by compiling through Dockerfile, and are pushed to image warehouse;Image B is the iterative version of image A;S2. export and save image A and image B into tar package, tar package includes each layer file, configuration json, manifest.json, repositories;S3. layer file is extracted from tar package and generated, layer file includes the difference layer file of image A and image B and original data file manifest.json, repositories.json, configuration json file;S4. the layer file generated in S3 is uploaded to private cloud server, and image A is pulled from image warehouse in private cloud server;S5. merge image A with the layer file generated in S3, modify the metadata RepoTags in manifest.json to modify image tag;Step S6. load new image tar package file, new image tar package file uses the new image tag in step S5;Step S7. new image tar package file is uploaded to image warehouse.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software application technology, and more specifically, to a method, system, device, and storage medium for updating Docker images. Background Technology

[0002] Docker images are stored in layers. Each instruction in the Dockerfile creates a new image layer. This layered image structure facilitates resource sharing, allowing different images to share the same image layers, significantly saving resources. In real-world applications, private servers cannot access the public internet. Each time a package is sent, the image needs to be saved as a local tar file and uploaded to the server remotely. For very large image files, uploading the entire image file to the private server each time is quite cumbersome. Sometimes, new versions of images only have minor modifications compared to older versions, sometimes only changing one or two image layers. In a private server production environment, uploading and updating large images is cumbersome, necessitating a more agile and lightweight update method. Summary of the Invention

[0003] The technical problem to be solved by the present invention is to address the above-mentioned shortcomings of the prior art. The purpose of the present invention is to provide a method for updating Docker images.

[0004] The second objective of this invention is to provide a system for updating Docker images.

[0005] The third objective of this invention is to provide a computer device.

[0006] The fourth objective of this invention is to provide a computer storage medium.

[0007] To achieve the first objective mentioned above, this invention provides a method for updating a Docker image, comprising the following steps:

[0008] Step S1. Compile Docker image A using Dockerfile and push it into the image repository; compile Docker image B using Dockerfile and push it into the image repository; Dockerfile consists of multiple instructions, including base image, code compilation instructions, and startup parameters; Docker image A and Docker image B have the same image layer, and Docker image B is an iterative version of Docker image A;

[0009] Step S2. Export and save Docker image A and Docker image B as tar archives. The tar archives contain the layer files, configuration JSON, manifest.json, and repositories.

[0010] Step S3. Extract and generate layer files from the tar package. The layer files include the difference layer files between Docker image A and Docker image B, as well as the original data files manifest.json, repositories.json, and configuration json files.

[0011] Step S4. Upload the layer file generated in step S3 to the private cloud server, and pull Docker image A from the image repository in the private cloud server;

[0012] Step S5. Merge Docker image A with the layer file generated in step 2 to obtain a new image tar package file;

[0013] Step S6. Load the new image tar file, which uses the new image tag from step S5;

[0014] Step S7. Upload the new image tar package file to the image repository to complete the Docker image update.

[0015] As a further improvement, in step S3, the specific extraction steps include:

[0016] Step S31. Parse the tar package files of Docker image A and Docker image B, compare the metadata file manifest.json, obtain the image difference layers of Docker image A and Docker image B, and generate a list of difference layer files;

[0017] Step S32. Compress the difference layer file, the original data files manifest.json, repositories.json, and the configuration json file into a layer file;

[0018] Step S33. The layer file, as a patch file, can be uploaded to the server containing Docker image A and merged to generate a new image tag.

[0019] Furthermore, in step S5, the specific merging steps include:

[0020] Step S51. Pull Docker image A from the image repository;

[0021] Step S52. Save and export Docker image A as a tar file;

[0022] Step S53. Obtain image layer information by parsing the original data file manifest.json in the layer compressed tar package;

[0023] Step S54. Parse the image layer files in the tar package of Docker image A, and check whether the missing image layer files in the Layers list of manifest.json in the layer tar package exist in the tar package of Docker image A, in addition to the image layer files contained in the layer tar package. If they do not exist, exit abnormally.

[0024] Step S55. Extract the image layer files from the Layers list in manifest.json, along with the original data files manifest.json, repositories.json, and configuration json files, and merge them into a new image tar package;

[0025] Step S56. Modify the metadata RepoTags in manifest.json to change the image tag.

[0026] To achieve the second objective mentioned above, this invention provides a system for updating Docker images, comprising:

[0027] The compilation module is used to compile Docker image A using a Dockerfile and push it into the image repository; it also compiles Docker image B using a Dockerfile and pushes it into the image repository. A Dockerfile consists of multiple instructions, including the base image, code compilation instructions, and startup parameters. Docker image A and Docker image B have the same image layer, and Docker image B is an iterative version of Docker image A.

[0028] The export module is used to export and save Docker image A and Docker image B as a tar package. The tar package contains the layer files, configuration JSON, manifest.json, and repositories.

[0029] The extraction module is used to extract and generate layer files from the tar package. The layer files include the difference layer files between Docker image A and Docker image B, as well as the original data files manifest.json, repositories.json, and configuration json files. The generated layer files are uploaded to a private cloud server, and Docker image A is pulled from the image repository in the private cloud server.

[0030] The merge module is used to merge Docker image A with the layer file generated by the extract module, modify the metadata RepoTags in manifest.json to modify the image tag, and obtain the new image tar package file;

[0031] The loading module is used to load the new image tarball file, which uses a new image tag; it also uploads the new image tarball file to the image repository, completing the Docker image update.

[0032] To achieve the third objective mentioned above, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-mentioned method for updating a Docker image.

[0033] To achieve the fourth objective mentioned above, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the above-described method for updating a Docker image.

[0034] Beneficial effects

[0035] Compared with the prior art, the advantages of this invention are as follows:

[0036] This invention solves the problem of needing to upload large image tar packages for image updates in private servers. By using image layer extraction and merging, only a very small layer package needs to be uploaded to merge and generate a new image on the private server, making the update process more agile and convenient. Attached Figure Description

[0037] Figure 1 This is a diagram illustrating Docker image A and Docker image B.

[0038] Figure 2 This is a flowchart illustrating the update process of the present invention. Detailed Implementation

[0039] The present invention will be further described below with reference to specific embodiments shown in the accompanying drawings.

[0040] See Figures 1-2 A method for updating a Docker image includes the following steps S1 to S7:

[0041] Step S1. Compile Docker image A using the Dockerfile and push it into the image repository; compile Docker image B using the Dockerfile and push it into the image repository. A Dockerfile consists of multiple instructions, including the base image, code compilation instructions, and startup parameters. For example... Figure 1As shown, Docker image A and Docker image B have the same image layer, and Docker image B is an iterative version of Docker image A. In the private cloud production server, image A already exists as an existing image and is currently in use. It is necessary to update image A to image B for version iteration.

[0042] Step S2. Export and save Docker image A and Docker image B as tar archives. The tar archives contain the layer files, configuration JSON, manifest.json, and repositories.

[0043] Step S3. Extract the generated layer files from the tar package. The layer files include the difference layer files between Docker image A and Docker image B, as well as the original data files manifest.json, repositories.json, and configuration json files.

[0044] In step S3, the specific extraction steps include:

[0045] Step S31. Parse the tar package files of Docker image A and Docker image B, compare the metadata file manifest.json, obtain the image difference layers of Docker image A and Docker image B, and generate a list of difference layer files;

[0046] Step S32. Compress the difference layer file, the original data files manifest.json, repositories.json, and the configuration json file into a layer file;

[0047] Step S33. The layer file can be uploaded as a patch file to the server with Docker image A, that is, upload the layer compressed file to the private cloud production server and merge it to generate a new image tag.

[0048] Step S4. Upload the layer file generated in step S3 to the private cloud server, and pull Docker image A from the image repository in the private cloud server.

[0049] Step S5. Merge Docker image A with the layer file generated in step S3, modify the metadata RepoTags in manifest.json to modify the image tag, modify the image tag to obtain a new image tag, and obtain a new image tar package file.

[0050] In step S5, the specific merging steps include:

[0051] Step S51. Pull Docker image A from the image repository, that is, pull image A from the private cloud production server image repository;

[0052] Step S52. Save and export Docker image A as a tar file;

[0053] Step S53. Obtain image layer information by parsing the original data file manifest.json in the layer compressed tar package;

[0054] Step S54. Parse the image layer files in the tar package of Docker image A, and check whether the missing image layer files in the Layers list of manifest.json in the layer tar package exist in the tar package of Docker image A, in addition to the image layer files contained in the layer tar package. If they do not exist, exit abnormally.

[0055] Step S55. Extract the image layer files from the Layers list in manifest.json, along with the original data files manifest.json, repositories.json, and configuration json files, and merge them into a new image tar package;

[0056] Step S56. Modify the metadata RepoTags in manifest.json to change the image tag.

[0057] Step S6. Load the new image tar file, which uses the new image tag from step S5.

[0058] Step S7. Upload the new image tar package file to the image repository to complete the Docker image update.

[0059] By extracting and merging layers of an image, only a very small layer package needs to be uploaded to merge and generate a new image on the private server. This solves the problem of having to upload large image tar packages when updating images on a private server, making the update process more agile and convenient.

[0060] A system for updating Docker images, comprising:

[0061] The compilation module is used to compile Docker image A using a Dockerfile and push it into the image repository; it also compiles Docker image B using a Dockerfile and pushes it into the image repository. A Dockerfile consists of multiple instructions, including the base image, code compilation instructions, and startup parameters. Docker image A and Docker image B have the same image layer, and Docker image B is an iterative version of Docker image A.

[0062] The export module is used to export and save Docker image A and Docker image B as a tar package. The tar package contains the layer files, configuration JSON, manifest.json, and repositories.

[0063] The extraction module is used to extract and generate layer files from the tar package. The layer files include the difference layer files between Docker image A and Docker image B, as well as the original data files manifest.json, repositories.json, and configuration json files. The generated layer files are then uploaded to a private cloud server, and Docker image A is pulled from the image repository on the private cloud server.

[0064] The merge module is used to merge Docker image A with the layer file generated by the extract module, modify the metadata RepoTags in manifest.json to modify the image tag, and obtain the new image tar package file;

[0065] The loading module is used to load the new image tarball file, which uses a new image tag; it also uploads the new image tarball file to the image repository, completing the Docker image update.

[0066] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the above-described method for updating a Docker image.

[0067] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described method for updating a Docker image.

[0068] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make several modifications and improvements without departing from the structure of the present invention, and these will not affect the effectiveness of the implementation of the present invention or the practicality of the patent.

Claims

1. A method for updating a Docker image, characterized in that, Includes the following steps: Step S1. Compile Docker image A using Dockerfile and push it into the image repository; The Dockerfile is used to compile Docker image B and push it into the image repository. The Dockerfile consists of multiple instructions, including the base image, code compilation instructions, and startup parameters. Docker image A and Docker image B have the same image layers, and Docker image B is an iterative version of Docker image A; Step S2. Export and save Docker image A and Docker image B as tar archives. The tar archives contain the layer files, configuration JSON, manifest.json, and repositories. Step S3. Extract and generate layer files from the tar package. The layer files include the difference layer files between Docker image A and Docker image B, as well as the original data files manifest.json, repositories.json, and configuration json files. Step S4. Upload the layer file generated in step S3 to the private cloud server, and pull Docker image A from the image repository in the private cloud server; Step S5. Merge Docker image A with the layer file generated in step S3, modify the metadata RepoTags in manifest.json to modify the image tag, and obtain the new image tar package file; Step S6. Load the new image tar file, which uses the new image tag from step S5; Step S7. Upload the new image tar package file to the image repository to complete the Docker image update; In step S3, the specific extraction steps include: Step S31. Parse the tar package files of Docker image A and Docker image B, compare the metadata file manifest.json, obtain the image difference layers of Docker image A and Docker image B, and generate a list of difference layer files; Step S32. Compress the difference layer file, the original data files manifest.json, repositories.json, and the configuration json file into a layer file; Step S33. The layer file, as a patch file, can be uploaded to the server containing Docker image A and merged to generate a new image tag; In step S5, the specific merging steps include: Step S51. Pull Docker image A from the image repository; Step S52. Save and export Docker image A as a tar file; Step S53. Obtain image layer information by parsing the original data file manifest.json in the layer compressed tar package; Step S54. Parse the image layer files in the tar package of Docker image A, and check whether the missing image layer files in the Layers list of manifest.json in the layer tar package exist in the tar package of Docker image A, in addition to the image layer files contained in the layer tar package. If they do not exist, exit abnormally. Step S55. Extract the image layer files from the Layers list in manifest.json, along with the original data files manifest.json, repositories.json, and configuration json files, and merge them into a new image tar package; Step S56. Modify the metadata RepoTags in manifest.json to change the image tag.

2. A system for updating Docker images, characterized in that, include: The compilation module is used to compile Docker image A using Dockerfile and push it into the image repository; Docker image B is compiled using Dockerfile and then pushed into the image repository; A Dockerfile consists of multiple instructions, including the base image, code compilation instructions, and startup parameters; Docker image A and Docker image B have the same image layers, and Docker image B is an iterative version of Docker image A; The export module is used to export and save Docker image A and Docker image B as a tar package. The tar package contains the layer files, configuration JSON, manifest.json, and repositories. The extraction module is used to extract and generate layer files from the tar package. The layer files include the difference layer files between Docker image A and Docker image B, as well as the original data files manifest.json, repositories.json, and configuration json files. The generated layer files are uploaded to a private cloud server, and Docker image A is pulled from the image repository in the private cloud server. The specific extraction process includes: Parse the tar package files of Docker image A and Docker image B, compare the metadata file manifest.json, obtain the image difference layers between Docker image A and Docker image B, and generate a list of difference layer files; Compress the difference layer file, the original data files manifest.json and repositories.json, and the configuration json file into a layer file; The layer file, as a patch file, can be uploaded to a server containing Docker image A and merged to generate a new image tag; The merge module is used to merge Docker image A with the layer files generated by the extract module. It modifies the metadata RepoTags in manifest.json to change the image tag and obtains a new image tarball file. The specific merge process includes: Pull Docker image A from the image repository; Save and export Docker image A as a tar file; The image layer information is obtained by parsing the manifest.json file, the original data file in the layer compressed tar package. Parse the image layer files in the tar package of Docker image A, and check whether the image layer files missing from the Layers list in the manifest.json of the layer tar package exist in the tar package of Docker image A. If they do not exist, exit abnormally. Extract the image layer files from the Layers list in manifest.json, along with the original data files manifest.json, repositories.json, and configuration json files, and merge them into a new image tar package; Modify the RepoTags metadata in manifest.json to change the image tag; The loading module is used to load the new image tarball file, which uses the new image tag; it also uploads the new image tarball file to the image repository, completing the Docker image update.

3. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the Docker image update method of claim 1.

4. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the Docker image update method of claim 1.

Citation Information

Patent Citations

  • Content updating method and system for Docker container, and server

    CN106528224A

  • Docker mirror image generation method and Docker container

    CN106933635A