Image processing method, device, electronic device and computer readable storage medium

By identifying the public data files in the container image and building a public image layer, the problem of reuse of data files during the image construction process is solved, and storage space is saved and deployment efficiency is improved.

CN113934510BActive Publication Date: 2025-03-25CHONGQING UNISINSIGHT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111211973.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-18
Publication Date
2025-03-25
Estimated Expiration
2041-10-18

AI Technical Summary

Technical Problem

In container technology, multiple images reuse the same data files during the build process, resulting in wasted storage resources and increasing the time and cost of deployment and migration.

Method used

Compression and reconstruction of mirrored data by determining the common data files of multiple images to be processed, building a common mirror layer, and retaining only other data files in each image when reconstructing the image, thereby realizing the compression and reconstruction of the mirror.

Benefits of technology

Effectively saves storage space, reduces storage costs, improves deployment and migration efficiency, and reduces redundant use of storage resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113934510B_ABST
    Figure CN113934510B_ABST
Patent Text Reader

Abstract

The image processing method, device, electronic device and computer-readable storage medium provided by the present invention, the image processing method provided by this embodiment, can realize the compression of image data and reduce the storage space occupied by the image. Specifically, in the process of image data processing, the method will first determine the common data files corresponding to multiple images to be processed, and then determine the common processing layer according to the common data files, with the purpose of merging the common data files to achieve the purpose of compressing the image data. When reconstructing, the reconstruction of the image is realized on the basis of retaining other data files except the common data files in each image to be processed, so that the image can share the same common image layer with the images of other applications on the server, and save storage space by merging the common data files to avoid file redundancy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of container technology, and in particular to an image processing method, device, electronic device and computer-readable storage medium. Background Art

[0002] At present, with the development of Internet technology and the increase in application demand, the utilization rate of network resources and storage resources, as well as the requirements for resource management, are becoming increasingly higher. Under this demand, container technology (Docker, Container) came into being and has developed rapidly.

[0003] Containers are a type of operating system virtualization, which are created based on images and are instantiations of images. In the actual project deployment process, there are usually multiple images and containers. These images may have the same data files, but in the process of building images, each image is built separately, resulting in the reuse of these same data files, occupying the storage resources of the container warehouse, resulting in higher storage costs and increasing the time consumption of service deployment and migration. Summary of the invention

[0004] One of the purposes of the present invention is to provide a mirror processing method, device, electronic device and computer-readable storage medium, which can save storage space, reduce storage costs and the time consumption of deployment and migration.

[0005] The embodiments of the present invention can be implemented as follows:

[0006] In a first aspect, the present invention provides an image processing method, the method comprising: determining common data files corresponding to multiple images to be processed; wherein the common data file is at least one of multiple data files in each of the images to be processed; each of the data files corresponds to an application; determining a common image layer based on the common data file; reconstructing the multiple images to be processed based on the common image layer and other data files in each of the images to be processed except the common data file.

[0007] In a second aspect, the present invention provides an image processing device, comprising: a determination module, used to determine the common data files corresponding to multiple images to be processed; wherein the common data file is at least one of the multiple data files to be installed for each of the images to be processed; each of the data files corresponds to an application; based on the common data files, a common image layer is determined; a construction module is used to reconstruct the multiple images to be processed based on the common image layer and other data files in each of the images to be processed except the common data files.

[0008] In a third aspect, the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the mirror processing method described in the first aspect.

[0009] In a fourth aspect, 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 image processing method described in the first aspect.

[0010] The present invention provides a method, device, electronic device and computer-readable storage medium for image processing. The image processing method provided in this embodiment can realize the compression of image data and reduce the storage space occupied by the image. Specifically, the method includes: determining the common data files corresponding to multiple images to be processed; wherein the common data file is at least one of the multiple data files in each of the images to be processed; each of the data files corresponds to an application; determining the common image layer according to the common data file; reconstructing the multiple images to be processed according to the common image layer and other data files in each of the images to be processed except the common data file. In the process of image data processing, the embodiment of the present application will first determine the common data files corresponding to the multiple images to be processed, so as to determine the common image layer according to the common data files, so as to realize the merging of the common data files and achieve the purpose of compressing the image data. When reconstructing, the reconstruction of the image is realized on the basis of retaining the other data files in each image to be processed except the common data files, so that the image can share the same common image layer with the images of other applications on the server, and save storage space by merging the common data files to avoid file redundancy. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0012] Figure 1 An example diagram of a configuration file provided in an embodiment of the present invention;

[0013] Figure 2 An application environment of the image processing method provided by an embodiment of the present invention;

[0014] Figure 3 A schematic flow chart of a mirror processing method provided by an embodiment of the present invention;

[0015] Figure 4 A schematic flow chart of an implementation method of step S301 provided in an embodiment of the present invention;

[0016] Figure 5 A schematic flowchart of an implementation method of step S301-3 provided in an embodiment of the present invention;

[0017] Figure 6 A schematic flowchart of an implementation method of step S303 provided in an embodiment of the present invention;

[0018] Figure 7 A directed graph provided by an embodiment of the present invention;

[0019] Figure 8 A functional module diagram of an image processing device provided by an embodiment of the present invention;

[0020] Fig. 9 A block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0021] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0022] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0024] In the description of the present invention, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear to indicate an orientation or position relationship, they are based on the orientation or position relationship shown in the accompanying drawings, or are the orientation or position relationship in which the product of the invention is usually placed when used. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.

[0025] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.

[0026] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.

[0027] The explanations of the professional terms involved in the embodiments of this application are as follows:

[0028] Image: is a file storage format that combines multiple files into a configuration file for easy distribution and use. Images use a layered image storage method, and an image can be composed of multiple image layers. For example, an image can contain a complete operating system environment. Images can be used to create containers. A container is a running instance created by an image. It can be started, started, stopped, and deleted. Each container is an isolated and secure platform.

[0029] Configuration file (Dockerfile): It is a text file used to build an image. The text content contains the instructions and instructions required to build the image. The content required to build the image is filled in the configuration file in the form of commands. When using the container management tool (for example: the docker command in the Linux operating system) to build the container image, the container management tool will read the command line by line and create a separate image layer for each line of command with characteristic characters (for example: RUN). After all commands are executed, the container image is generated.

[0030] For ease of understanding, the following combination Figure 1 Describe the configuration file. Figure 1 The following are sample configuration files of two images. Take image 1 as an example, where "RUN" refers to the command executed when building the image. The command line contains the application data files (that is, data packets): wget, curl, net-tools, vim, python, and opencv.

[0031] Data file: refers to the data package corresponding to the application, which can be but is not limited to game applications, social software, audio and video applications, office software, etc.

[0032] Public image layer: refers to combining multiple public data files together to establish an image layer. Different images can share a public image layer.

[0033] The embodiments of the present application do not limit the applicable scenarios of the image processing method in the embodiments of the present application, and can be applied to any scenario where the container image of the application needs to be compressed.

[0034] See also Figure 2 , Figure 2 The application environment of the image processing method provided by the embodiment of the present invention includes a first server 210 , a network 230 and a second server 220 .

[0035] The first server 210 can be an image production server, used to process images, including but not limited to producing images or compressing images; it can also distribute the produced or compressed images to the second server. The second server 220 can be an application server, used to run the obtained images to implement corresponding application functions; the second server 220 can also be an image storage server, used to store the images produced or compressed by the first server 210.

[0036] Among them, the first server 210 and the second server 220 can be independent physical servers, or they can be a server cluster or distributed system composed of multiple physical servers. The above-mentioned network 230 can include but is not limited to: wired network, wireless network, wherein the wired network includes: local area network, metropolitan area network and wide area network, and the wireless network includes: Bluetooth, Wi-Fi and other networks that realize wireless communication.

[0037] The image processing method in the embodiment of the present invention can be applied to the first server 210. The first server 210 reconstructs multiple images to be processed, thereby compressing multiple container images in the system, reducing the storage and time overhead of the system during deployment, expansion, and migration, and improving efficiency.

[0038] Continue with Figure 1 and Figure 2 For example, in the process of building image 1 and image 2, the prior art will build six data files, namely wget, curl, net-tools, vim, python and opencv, in the same image layer for image 1. Similarly, wget, curl, net-tools, vim and node will be built in the same image layer when building image 2. Since data files are cached when building images, it can be seen that the first server 210 will repeatedly cache the same data files in images 1 and 2, namely "wget, curl, net-tools, vim", which will increase storage costs.

[0039] Furthermore, the above construction method will also increase the storage and time overhead of the system during deployment, expansion, and migration. For example, a service system usually consists of multiple microservices, each of which implements a relatively independent function. The container orchestration tool (such as Kubernetes) is responsible for the container orchestration tasks and the container startup and expansion of each service. If the service system needs to be migrated to another environment, it is usually necessary to export the images corresponding to each microservice and then import the image files. However, these images are likely to have potentially identical data files, which will increase the size of the deployment data package during the migration process, reducing the efficiency of deployment and migration.

[0040] In order to solve the above problems, an embodiment of the present invention provides a mirror processing method, which can be applied in Figure 2 On the first server 210 shown, see Figure 3 , Figure 3 A schematic flow chart of a mirror processing method provided by an embodiment of the present invention, the method may include:

[0041] S301: Determine common data files corresponding to multiple images to be processed.

[0042] The public data file is at least one of the multiple data files in each image to be processed; and each data file corresponds to an application program.

[0043] For example, see Figure 1 , the common data files may be data files of applications "wget, curl, net-tools, vim" that both image 1 and image 2 have.

[0044] S302: Determine a public image layer according to the public data file.

[0045] S303: Reconstruct multiple images to be processed according to the common image layer and other data files in each image to be processed except the common data file.

[0046] It can be understood that by building the common data files in the same image layer, the common data files only need to be cached once when reconstructing the image to be processed, and there is no need to cache the common data files every time an image to be processed is built, thereby preventing file redundancy and layer redundancy, and significantly reducing the size of multiple images to be processed in the warehouse.

[0047] The image processing method provided in this embodiment can realize the compression of image data and reduce the storage space occupied by the image. Specifically, in the process of image data processing, the method will first determine the common data files corresponding to multiple images to be processed, and then build a common processing layer according to the common data files to realize the merging of the common data files, so as to achieve the purpose of compressing the image data. When reconstructing, the reconstruction of the image is realized on the basis of retaining other data files except the common data files in each image to be processed, so that the image can share the same common image layer with the images of other applications on the server, and save storage space by merging common data files to avoid file redundancy.

[0048] Optionally, a method for determining the common data files corresponding to multiple images to be processed is also given below. Figure 4 , Figure 4 A schematic flowchart of an implementation method of step S301 provided in an embodiment of the present invention, wherein step S301 may include:

[0049] S301-1. Obtain identification information of each image to be processed.

[0050] In this embodiment, the identification information may be a unique identifier of the image to be processed, which may be input to the server by a user, or read from a memory after the server is started, which is not limited here.

[0051] S301 - 2. Obtain a configuration file corresponding to each image to be processed according to the identification information.

[0052] It is understandable that after successfully building an image, the server will generate a configuration file corresponding to the image. The configuration file is as follows: Figure 1 As shown, no further description is given here.

[0053] In one scenario, when a configuration file exists in the server, it can be directly read according to the identification information.

[0054] In another scenario, when there is no configuration file in the server but there is a history record of the image build, the build record information corresponding to the identification information can be directly read according to each identification information through the identification information, and the build record information can be converted into a configuration file.

[0055] S301-3. Determine a common data file according to the target command field used to construct the image to be processed in each configuration file.

[0056] In this embodiment, the target command field can be as follows: Figure 1 The apt-get (apt) install command in the RUN instruction shown can also be an ADD command or a COPY command when there is no directory conflict.

[0057] The following is a possible implementation method for determining the public data file in step S301-3. Figure 5 , Figure 5 A schematic flowchart of an implementation method of step S301-3 provided in an embodiment of the present invention, wherein step S301-3 may include:

[0058] S301-3-1. Parse the target command field in each configuration file to obtain a data file set corresponding to each image to be processed.

[0059] In this embodiment, to parse the target command field in each configuration file, it is actually necessary to first determine the target command field in the configuration file. In one scenario, when there is a command field in the configuration file that is consistent with a predefined command field, the command field is determined as the target command field. For example, the apt-get (apt) install command in the RUN statement is the target command field. In another scenario, judgment rules can also be pre-defined to determine the target command field. For example, the ADD command and the COPY command in the case of no directory conflict can both be used as the target command field.

[0060] S301-3-2. The union of all data file sets is used as the target data file set.

[0061] S301-3-3. Determine the public data file according to the target data file set.

[0062] It can be understood that by parsing the configuration file of each image to be processed, a data file set Si can be obtained, and the target data file set Sa can be obtained by union of these Si, and then the common data files can be determined according to the target data file set Sa.

[0063] To facilitate understanding of the above steps, Figure 1 This article uses image 1 in the example.

[0064] For the Dockerfile of image 1, split the RUN statement and parse out each command and parameter in the statement. If a RUN statement consists of multiple commands, parse these commands in sequence and concatenate them in sequence, preferably in an array. Each image corresponds to an array, so for the splitting of the Dockerfile of image 1, split the installation packages of apt-getinstall one by one to form a concatenated array:

[0065] ["FROM ubuntu:16.04","RUN apt-get install wget","RUN apt-get installcurl","RUN apt-get install net-tools","RUN apt-get install vim","RUN apt-getinstall python","RUN apt-get install opencv",...,"CMD[' / usr / bin / python','xxx.py']"]

[0066] Because apt-get install is an exchange command, these commands are abstracted into elements of a set. Here, some characters of the command are omitted for simplicity. The data file set corresponding to the Dockerfile of image 1 is:

[0067] S1={"wget","curl","net-tools","vim","python","opencv"}.

[0068] Similarly, the data file set corresponding to the Dockerfile of image 2 is:

[0069] S2={"wget","curl","net-tools","vim","node"}.

[0070] Furthermore, the union of S1 and S2 can determine Sa as:

[0071] Sa={"wget","curl","net-tools","vim","python","opencv","node"}.

[0072] Then, the public data file can be determined according to Sa. A possible implementation method is given below, that is, the above step S301-3-3 may include the following steps:

[0073] The first step is to determine all non-empty true subsets corresponding to the target data file set.

[0074] In the second step, based on all non-empty true subsets, a target non-empty true subset that meets the first preset condition and the second preset condition is screened out.

[0075] Among them, the first preset condition is: the intersection of the target non-empty true subset and any data file set is the target non-empty true subset or the empty set; the second preset condition is: the difference between the target non-empty true subset and the target data file set, and the intersection with the target non-empty true subset does not meet the first preset condition.

[0076] In the third step, all data files in a target non-empty true subset with the largest number of data files are determined as public data files.

[0077] That is to say, for Sa, obtain all its non-empty proper subsets A={Aj}, traverse the set A, and screen the set Aj that satisfies both the first preset condition and the second preset condition.

[0078] First precondition: Aj and any Si satisfy: Aj&Si=A or Aj&Si=empty, where & represents the intersection operation of sets.

[0079] The second preset condition: Aj is the maximum set, that is, any element in Aj and the difference set Ap between Sa and Aj does not satisfy condition 1.

[0080] For ease of understanding, continue with Figure 1 The mirror image 1 and mirror image 2 shown are used as examples for explanation.

[0081] By screening the non-empty true subset of Sa={"wget","curl","net-tools","vim","python","opencv","node"}, we finally get the target non-empty true subset Sj=[{"wget","curl","net-tools","vim"},{"python","opencv"},{"node"}] that meets the first preset condition and the second preset condition. It can be seen that {"wget","curl","net-tools","vim"} has the largest number of data files, so "wget","curl","net-tools","vim" are all public data files.

[0082] Optionally, an implementation method for reconstructing the image to be processed is also given below, see Figure 6 , Figure 6 A schematic flowchart of an implementation method of step S303 provided in an embodiment of the present invention, wherein step S303 may include:

[0083] S303-1. Construct a directed graph based on the data files in all target non-empty proper subsets;

[0084] Among them, each node in the directed graph corresponds to a data file; one of the public data files is the fork node of the directed graph; and the data file corresponding to each node before the fork node corresponds to the public image layer.

[0085] It is understandable that the above directed graph can be constructed by restoring the command statement corresponding to the target non-empty proper subset Aj, combining the command statement corresponding to Aj and the array corresponding to the image to be processed, and constructing a directed graph, that is, traversing the array corresponding to the original image to be processed, and if the element is in the set Aj, select the set Aj as the node and connect them. Until the end.

[0086] S303-2, reconstructing multiple images to be processed according to the data file set, the common image layer and the directed graph corresponding to each image to be processed.

[0087] Continue below Figure 1 For example, the target non-empty proper subsets corresponding to image 1 and image 2 are Sj = [{"wget","curl","net-tools","vim"},{"python","opencv"},{"node"}]. Combined with S1 = {"wget","curl","net-tools","vim","python","opencv"} corresponding to image 1, S2 = {"wget","curl","net-tools","vim","node"} corresponding to the Dockerfile of image 2.

[0088] For example, according to the order of elements of Sj, the data files in {"wget", "curl", "net-tools", "vim"} are connected as nodes in sequence. It should be noted that the order of data elements in each set can be exchanged. Assuming that "vim" is a cross node, any one of {"python", "opencv"} and any one of {"node"} are connected as child nodes of the cross node in sequence; then for each child node, the same logic as above is followed to connect the data files in the same set as the child node until all data files are connected as nodes to obtain the final directed graph, as shown in FIG. Figure 7 As shown, Figure 7 A directed graph is provided in an embodiment of the present invention.

[0089] Then, we use the depth-first algorithm to traverse the directed graph and get the mirror-constructed statements. Figure 7 Before the forked node, merge the command statements as the common image layer, regenerate the configuration file of each image to be processed, and then reconstruct each image to be processed according to the regenerated configuration file.

[0090] For ease of understanding, continue with Figure 1 For example, based on the directed graph, the public image layer, and the data file set of image 1, the configuration file of image 1 is regenerated as follows:

[0091] FROM ubuntu:16.04

[0092] RUN apt-get install wget curl net-tools vim

[0093] RUN apt-get install python opencv ...

[0094] CMD[' / usr / bin / python','xxx.py']

[0095] According to the directed graph, the common image layer and the data file set of image 2, the configuration file of image 2 is regenerated as follows:

[0096] ROM ubuntu:16.04

[0097] RUN apt-get install wget curl net-tools vim

[0098] RUN apt-get install node ...

[0099] CMD[' / usr / bin / node','xxx.js']

[0100] From the above results, we can see that in the configuration files regenerated by Mirror 1 and Mirror 2, there is a common image layer, namely, wget curl net-tools vim. In other words, wget curl net-tools vim is built on the same layer, so that Mirror 1 and Mirror 2 can share this layer, which is the same as Figure 1 Compared with the configuration files in , the embodiment of the present application does not need to repeatedly build the image layer for wget curl net-tools vim, nor does it need to repeatedly cache the same data, which obviously saves storage space.

[0101] In order to implement the various steps in the above embodiments to achieve the corresponding technical effects, the image processing method provided in the embodiment of the present invention can be executed in a hardware device or in the form of a software module. When the image processing method is implemented in the form of a software module, the embodiment of the present invention also provides an image processing device, see Figure 8 , Figure 8 The functional module diagram of the image processing device provided by the embodiment of the present invention, the image processing device 400 may include:

[0102] The determination module 410 is used to determine the common data files corresponding to the multiple images to be processed; wherein the common data file is at least one of the multiple data files to be installed for each of the images to be processed; each of the data files corresponds to an application; and a common image layer is determined based on the common data files.

[0103] The construction module 420 is used to reconstruct the multiple images to be processed according to the common image layer and other data files in each of the images to be processed except the common data file.

[0104] It is understandable that the determination module 410 and the construction module 420 can be executed in coordination. Figure 3 to achieve the corresponding technical effects.

[0105] In some possible implementations, the determination module 410 is specifically used to: obtain identification information of each of the images to be processed; obtain a configuration file corresponding to each of the images to be processed based on the identification information; and determine the common data file based on a target command field in each of the configuration files used to construct the images to be processed.

[0106] In some possible implementations, the determination module 410 is further specifically used to parse the target command field in each of the configuration files to obtain a data file set corresponding to each of the images to be processed; take the union of all the data file sets as the target data file set; and determine the common data file based on the target data file set.

[0107] In some possible implementations, the determination module 410 is further specifically used to determine all non-empty true subsets corresponding to the target data file set; based on the all non-empty true subsets, the target non-empty true subsets that meet the first preset condition and the second preset condition are screened out; wherein the first preset condition is: the intersection of the target non-empty true subset and any one of the data file sets is the target non-empty true subset or an empty set; the second preset condition is: the difference between the target non-empty true subset and the target data file set, and the intersection with the target non-empty true subset does not meet the first preset condition. All data files in the target non-empty true subset with the largest number of data files are determined as the public data files.

[0108] In some possible implementations, the construction module 420 is specifically used to reconstruct the multiple images to be processed based on the common image layer and other data files in each of the images to be processed except the common data file, including: constructing a directed graph based on the data files in all the target non-empty true subsets; wherein each node in the directed graph corresponds to a data file; one of the common data files is a fork node of the directed graph; the data file corresponding to each node before the fork node corresponds to the common image layer; reconstructing the multiple images to be processed based on the set of data files corresponding to each of the images to be processed, the common image layer and the directed graph.

[0109] In some possible implementations, the determination module 410 is also specifically used to parse the target command field corresponding to each of the configuration files, including: determining the target command field in the configuration file according to a predefined command field or a preset judgment rule; and parsing the configuration file according to the determined target command field.

[0110] In some possible implementations, the determination module 410 is further specifically used to read the configuration file corresponding to the identification information according to each of the identification information; or, to read the build record information corresponding to the identification information according to each of the identification information, and convert the build record information into the configuration file.

[0111] An image processing device provided by an embodiment of the present invention determines a plurality of public data files corresponding to images to be processed through a determination module; wherein the public data file is at least one of a plurality of data files to be installed for each of the images to be processed; each of the data files corresponds to an application; a public image layer is determined according to the public data file; and the plurality of images to be processed are reconstructed according to the public image layer and other data files in each of the images to be processed except the public data file through a construction module. The image data can be compressed to reduce the storage space occupied by the image.

[0112] It should be noted that the various functional modules in the image processing device 400 of the embodiment of the present invention can be stored in the memory in the form of software or firmware or solidified in the operating system (OS) of the electronic device, and can be executed by the processor in the electronic device. At the same time, the data and program codes required to execute the above modules can be stored in the memory.

[0113] Therefore, an embodiment of the present invention further provides an electronic device, which may be Figure 1 The first server 210 shown, or other electronic devices with data processing functions, is not limited in the present invention.

[0114] like Fig. 9 , Fig. 9 A block diagram of an electronic device provided in an embodiment of the present invention. The electronic device 500 includes a communication interface 501, a processor 502 and a memory 503. The processor 502, the memory 503 and the communication interface 501 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The memory 503 can be used to store software programs and modules, such as program instructions / modules corresponding to the mirror processing method provided in an embodiment of the present invention. The processor 502 executes the software programs and modules stored in the memory 503 to perform various functional applications and data processing. The communication interface 501 can be used to communicate signaling or data with other node devices. In the present invention, the electronic device 50 can have multiple communication interfaces 501.

[0115] Among them, the memory 503 can be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc.

[0116] The processor 502 may be an integrated circuit chip with signal processing capability. The processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0117] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the image processing method in any of the above-mentioned embodiments is implemented. The computer-readable storage medium can be, but is not limited to, a U disk, a mobile hard disk, a ROM, a RAM, a PROM, an EPROM, an EEPROM, a magnetic disk, or an optical disk, etc., various media that can store program codes.

[0118] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A mirror processing method, characterized in that: The method comprises: Determine a common data file corresponding to a plurality of images to be processed; wherein the common data file is at least one of a plurality of data files in each of the images to be processed; and each of the data files corresponds to an application; Determine a public image layer according to the public data file; Reconstructing the multiple images to be processed according to the common image layer and other data files in each of the images to be processed except the common data file; Determining the common data files corresponding to the plurality of images to be processed, comprising: obtaining identification information of each of the images to be processed; obtaining a configuration file corresponding to each of the images to be processed according to the identification information; determining the common data file according to a target command field for constructing the image to be processed in each of the configuration files; Determining the common data file according to the target command field for constructing the image to be processed in each of the configuration files, including: parsing the target command field in each of the configuration files to obtain a data file set corresponding to each of the images to be processed; taking the union of all the data file sets as the target data file set; and determining the common data file according to the target data file set; Determining the public data file according to the target data file set includes: determining all non-empty true subsets corresponding to the target data file set; and screening out target non-empty true subsets that meet a first preset condition and a second preset condition according to all non-empty true subsets; Among them, the first preset condition is: the intersection of the target non-empty true subset and any one of the data file sets is the target non-empty true subset or an empty set; the second preset condition is: the difference between the target non-empty true subset and the target data file set and the intersection of the target non-empty true subset do not meet the first preset condition; all data files in the target non-empty true subset with the largest number of data files are determined as the common data files.

2. The mirror processing method according to claim 1, characterized in that: Reconstructing the plurality of images to be processed according to the common image layer and other data files in each of the images to be processed except the common data file, comprises: Constructing a directed graph according to the data files in all the target non-empty proper subsets; Each node in the directed graph corresponds to a data file; one of the public data files is a fork node of the directed graph; and the data file corresponding to each node before the fork node corresponds to the public image layer; The multiple images to be processed are reconstructed according to the data file set corresponding to each of the images to be processed, the common image layer and the directed graph.

3. The mirror processing method according to claim 1, characterized in that: Parsing the target command field in each of the configuration files includes: Determining the target command field in the configuration file according to a predefined command field or a preset determination rule; The configuration file is parsed according to the determined target command field.

4. The mirror processing method according to claim 1, characterized in that: Obtaining a configuration file corresponding to each of the to-be-processed images according to the identification information includes: According to each piece of identification information, read a configuration file corresponding to the identification information; or, According to each piece of identification information, the construction record information corresponding to the identification information is read, and the construction record information is converted into the configuration file.

5. A mirror processing device, characterized in that: include: A determination module, used to determine a common data file corresponding to a plurality of images to be processed; wherein the common data file is at least one of a plurality of data files to be installed for each of the images to be processed; each of the data files corresponds to an application; and a common image layer is determined according to the common data file; A construction module, used for reconstructing the plurality of images to be processed according to the common image layer and other data files in each of the images to be processed except the common data file; The determination module is specifically used to: obtain identification information of each of the images to be processed; obtain a configuration file corresponding to each of the images to be processed according to the identification information; and determine the public data file according to a target command field used to construct the image to be processed in each of the configuration files; The determination module is further specifically used to: parse the target command field in each of the configuration files to obtain a data file set corresponding to each of the to-be-processed images; take the union of all the data file sets as a target data file set; and determine the common data file according to the target data file set; The determination module is further specifically used to: determine all non-empty true subsets corresponding to the target data file set; screen out target non-empty true subsets that meet a first preset condition and a second preset condition based on the all non-empty true subsets; wherein the first preset condition is: the intersection of the target non-empty true subset and any one of the data file sets is the target non-empty true subset or an empty set; the second preset condition is: the difference between the target non-empty true subset and the target data file set and the intersection of the target non-empty true subset do not meet the first preset condition; and determine all data files in the target non-empty true subset with the largest number of data files as the common data files.

6. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the mirror processing method according to any one of claims 1 to 4.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image processing method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Construction method and system of cloud computing mirror image document

    CN105404506A

  • Docker mirror image construction method, device, storage medium and electronic apparatus

    CN107491329A