Mirror management method and server
By layering the application's software packages and dependencies, image layering information is generated, which solves the problem of improper trimming in container image creation and enables normal image use and optimized storage space.
Patent Information
- Application Number
- CN202410123210.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-29
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2044-01-29
AI Technical Summary
Existing image management methods may result in improper trimming during container image creation, leading to unusable container images, especially when the trimmed packages are dependent on by other applications.
By obtaining the application's software packages and their dependencies, layering is performed to generate image layering information. Based on this information, image generation files are created, ultimately producing a container image.
The container image creation process has been optimized to ensure that the generated images can be used normally, and layered sharing of container images and optimization of storage space have been achieved.
Smart Images

Figure CN117971782B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of server technology, and in particular to a mirror management method and server. Background Technology
[0002] Containers and containerization technology are lightweight virtualization technologies. An image is one of the core components of containers and containerization technology; it is a special file system. An image contains the complete root file system of an operating system, and its size is often enormous. In Docker's design, union file system technology can be fully utilized to design it as a layered storage architecture to achieve layered sharing of images.
[0003] Image management methods in related technologies require generating a container image based on the application's software package and multiple other software packages (including packages the application package depends on and packages the application package does not depend on). During application runtime, the software packages that the application's software package depends on are analyzed, and other packages that the application's software package does not depend on are trimmed or removed.
[0004] However, existing image management methods may result in instances where other software packages are cut out and depended upon by other applications, potentially causing container images to malfunction. Therefore, there is an urgent need for an image management method that can optimize the creation of container images for at least one application. Summary of the Invention
[0005] This application provides an image management method and server that can optimize the creation of container images for at least one application.
[0006] In a first aspect, embodiments of this application provide a mirror management method, including:
[0007] Obtain at least one application's software package; wherein, each application's software package records the application's dependency information, which is used to indicate the dependency relationship between the application's software package and at least one dependent package;
[0008] Based on the dependency information, the software packages and at least one dependent package of each application are layered to obtain image layering information. The image layering information is used to represent the information of the software packages and at least one dependent package of each application arranged in a layered manner according to the dependency relationship.
[0009] Based on the image layering information, generate the image file corresponding to each application;
[0010] Generate a container image for each application based on the image generation file corresponding to each application.
[0011] The beneficial effects of this embodiment are as follows: Based on the dependency information recorded in the software package, this embodiment performs layered processing on the software package and at least one dependent package of each application to determine the image layering information, and then generates an image generation file for making a container image. In this way, the creation of the application's container image is optimized, so that the generated container image can be used normally.
[0012] In one implementation, based on dependency information, the software package and at least one dependent package of each application are layered to obtain image layering information, including:
[0013] When multiple application packages are obtained, the dependency information of the multiple applications is merged to obtain the overall dependency information;
[0014] Based on the overall dependency information, the software packages and at least one dependency package of each application are layered to obtain image layering information.
[0015] The beneficial effects of this implementation are as follows: Before generating the container image corresponding to an application, the dependency information of multiple applications is merged to obtain overall dependency information. Then, based on the overall dependency information, the software package and at least one dependent package of each application are layered to obtain image layering information. Based on the image layering information, an image generation file is generated, and then a container image corresponding to each application is generated based on the image generation file corresponding to each application. Through the above method, the layered sharing capability of container images is realized, and the creation of multiple container images can be optimized simultaneously.
[0016] In one implementation, the image layering information includes at least common layer information, first sub-layer information, and second sub-layer information. The common layer information includes at least one common dependency package. The first sub-layer information includes the application-specific dependency package and the application's software package. The second sub-layer information includes the application-specific dependency package and the application's software package. Based on the image layering information, an image generation file corresponding to each application is generated, including:
[0017] Based on the public dependency packages, the first application's proprietary dependency packages, and the first application's software packages, generate the image file corresponding to the first application;
[0018] Based on the public dependency packages, the second application's proprietary dependency packages, and the second application's software packages, generate the corresponding image file for the second application.
[0019] The beneficial effects of this implementation are: the server can generate the image file corresponding to the first application based on the common dependency package, the first application's dedicated dependency package, and the first application's software package; the server can also generate the image file corresponding to the second application based on the common dependency package, the second application's dedicated dependency package, and the second application's software package. Through this method, while maintaining the layered sharing capability of container images, it achieves joint optimization of multiple images.
[0020] In one implementation, the dependency information of multiple applications is merged to obtain overall dependency information, including:
[0021] Based on the dependency information of each application, a directed acyclic graph is generated for each application. In the directed acyclic graph, the source node and the dependency node represent the application's software package and dependency package, respectively. The connection between dependency nodes represents the dependency relationship between dependency packages, and the connection between the source node and the dependency node represents the dependency relationship between the application's software package and dependency package.
[0022] The directed acyclic graphs of multiple applications are merged to obtain a multi-source directed acyclic graph, which is then used to determine the overall dependency information.
[0023] The beneficial effects of this implementation are as follows: This embodiment utilizes the directed acyclic graph (DAG) characteristic to convert the dependency information of each application into a DAG, and then merges them into a multi-source DAG that reflects the overall dependency information. Through this method, rapid analysis of the overall dependency relationship is achieved.
[0024] In one implementation, based on the overall dependency information, the software packages and at least one dependent package of each application are layered to obtain image layering information, including:
[0025] Based on the connection relationships of each node in each directed acyclic graph, the multi-source directed acyclic graph is processed into layers to generate layer node graphs, and the layer node graphs are determined as mirror layer information.
[0026] The beneficial effects of this implementation are: based on the multi-source directed acyclic graph, the layer node graph that can be used for mirror layering is determined. Through this method, the mirror layering information can be determined quickly.
[0027] In one implementation, the multi-source directed acyclic graph is layered based on the connection relationships between nodes in each directed acyclic graph to generate a layered node graph, including:
[0028] Dependent nodes that are connected to the same source node are identified as dependent nodes at the same connection level.
[0029] For each source node, the connection hierarchy corresponding to the dependent nodes that are connected to the source node but not connected to other source nodes is determined as the connection hierarchy corresponding to the source node.
[0030] Based on the connection hierarchy corresponding to each source node and the connection hierarchy corresponding to each dependent node, the multi-source directed acyclic graph is processed into layers to generate a layered node graph.
[0031] The beneficial effects of this implementation are as follows: In this embodiment, dependent nodes connected to the same source node are identified as dependent nodes at the same connection level. For each source node, the connection level corresponding to the dependent nodes connected to the source node but not connected to other source nodes is identified as the connection level corresponding to the source node. Based on the connection levels corresponding to each source node and each dependent node, the multi-source directed acyclic graph is layered to generate a layered node graph. Through this method, reasonable layering of application software packages and dependent packages can be achieved, thereby reducing the overall storage space occupied by multiple container images and the storage space occupied by a single container image. In other words, it optimizes both the individual container image and the overall container image.
[0032] In one implementation, directed acyclic graphs from multiple applications are merged to obtain a multi-source directed acyclic graph, including:
[0033] Create a blank drawing;
[0034] For each application's directed acyclic graph, if there is no source node in the blank graph that is the same as the source node in the directed acyclic graph, then the corresponding source node is created in the blank graph to update the blank graph.
[0035] If there is no dependent node in the blank graph that is the same as the dependent node in the directed acyclic graph, then the corresponding dependent node is created in the blank graph to update the blank graph.
[0036] If there is no connection in the blank graph that is the same as the connection relationship in the directed acyclic graph, then the corresponding connection relationship is created in the blank graph to update the blank graph;
[0037] The updated blank graph is identified as a multi-source directed acyclic graph.
[0038] The beneficial effects of this implementation are: In a blank graph, multiple source nodes, dependent nodes, or connection relationships corresponding to source nodes, dependent nodes, or connection relationships in directed acyclic graphs (DAGs) can be created to obtain a multi-source DAG. This method enables the rapid merging of DAGs from multiple applications.
[0039] One implementation also includes:
[0040] Obtain the upgraded application's software package; the upgraded application's software package contains the upgraded application's dependency information;
[0041] If it is determined that the dependency information of the upgraded application is the same as that of the application before the upgrade, then obtain the image generation file corresponding to the application.
[0042] Based on the upgraded application's software package, modify the corresponding image generation file for the application to obtain the modified image generation file;
[0043] Generate the container image corresponding to the upgraded application based on the modified image generation file.
[0044] The beneficial effects of this implementation are as follows: Compared with related technologies, when the application software package is upgraded, the server needs to re-analyze the dependency packages that the upgraded software package depends on at runtime and perform image trimming, resulting in low image generation efficiency and image optimization efficiency. In this embodiment, the image generation file corresponding to the application can be reused when the dependency information has not changed, thereby improving the generation efficiency and optimization efficiency of container images.
[0045] In one implementation, a container image for each application is generated based on the image generation file corresponding to each application, including:
[0046] Generate a container image for the first application based on the image generation file corresponding to the first application.
[0047] Generate a container image for the second application based on the image generation file corresponding to the second application.
[0048] The beneficial effects of this implementation are as follows: In this embodiment, the server can generate a container image corresponding to the first application based on the image generation file corresponding to the first application, and generate a container image corresponding to the second application based on the image generation file corresponding to the second application. Through this method, the rapid creation of container images corresponding to the first and second applications is achieved.
[0049] Secondly, embodiments of this application provide a mirror management device, including:
[0050] The dependency resolution module is used to obtain the software packages of at least one application; wherein, the software package of each application records the application's dependency information, which is used to represent the dependency relationship between the application's software package and at least one dependent package;
[0051] The dependency analysis module is used to perform layered processing on the software packages and at least one dependent package of each application based on dependency relationship information, and obtain image layering information. The image layering information is used to represent the information of the software packages and at least one dependent package of each application arranged in a layered manner according to dependency relationships.
[0052] The image generation file generation module is used to generate image generation files for each application based on the image layering information.
[0053] The image creation module is used to generate container images for each application based on the image file corresponding to each application.
[0054] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0055] In one implementation, the dependency analysis module is specifically used for:
[0056] When multiple application packages are obtained, the dependency information of the multiple applications is merged to obtain the overall dependency information;
[0057] Based on the overall dependency information, the software packages and at least one dependency package of each application are layered to obtain image layering information.
[0058] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0059] In one implementation, the image layering information includes at least common layer information, first sub-layer information, and second sub-layer information. The common layer information includes at least one common dependency package. The first sub-layer information includes the application-specific dependency package and the application's software package. The second sub-layer information includes the application-specific dependency package and the application's software package. The image generation file generation module is specifically used for:
[0060] Based on the public dependency packages, the first application's proprietary dependency packages, and the first application's software packages, generate the image file corresponding to the first application;
[0061] Based on the public dependency packages, the second application's proprietary dependency packages, and the second application's software packages, generate the corresponding image file for the second application.
[0062] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0063] In one implementation, the dependency analysis module is specifically used for:
[0064] Based on the dependency information of each application, a directed acyclic graph is generated for each application. In the directed acyclic graph, the source node and the dependency node represent the application's software package and dependency package, respectively. The connection between dependency nodes represents the dependency relationship between dependency packages, and the connection between the source node and the dependency node represents the dependency relationship between the application's software package and dependency package.
[0065] The directed acyclic graphs of multiple applications are merged to obtain a multi-source directed acyclic graph, which is then used to determine the overall dependency information.
[0066] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0067] In one implementation, the dependency analysis module is specifically used for:
[0068] Based on the connection relationships of each node in each directed acyclic graph, the multi-source directed acyclic graph is processed into layers to generate layer node graphs, and the layer node graphs are determined as mirror layer information.
[0069] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0070] In one implementation, the dependency analysis module is specifically used for:
[0071] Dependent nodes that are connected to the same source node are identified as dependent nodes at the same connection level.
[0072] For each source node, the connection hierarchy corresponding to the dependent nodes that are connected to the source node but not connected to other source nodes is determined as the connection hierarchy corresponding to the source node.
[0073] Based on the connection hierarchy corresponding to each source node and the connection hierarchy corresponding to each dependent node, the multi-source directed acyclic graph is processed into layers to generate a layered node graph.
[0074] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0075] In one implementation, the dependency analysis module is specifically used for:
[0076] Create a blank drawing;
[0077] For each application's directed acyclic graph, if there is no source node in the blank graph that is the same as the source node in the directed acyclic graph, then the corresponding source node is created in the blank graph to update the blank graph.
[0078] If there is no dependent node in the blank graph that is the same as the dependent node in the directed acyclic graph, then the corresponding dependent node is created in the blank graph to update the blank graph.
[0079] If there is no connection in the blank graph that is the same as the connection relationship in the directed acyclic graph, then the corresponding connection relationship is created in the blank graph to update the blank graph;
[0080] The updated blank graph is identified as a multi-source directed acyclic graph.
[0081] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0082] In one implementation,
[0083] The dependency resolution module is also used to obtain the package of the upgraded application; the package of the upgraded application records the dependency information of the upgraded application.
[0084] The dependency resolution module is also used to obtain the corresponding image generation file of the application if it is determined that the dependency information of the upgraded application is the same as that of the application before the upgrade.
[0085] The image generation file generation module is also used to modify the image generation file corresponding to the application based on the upgraded application's software package, and obtain the modified image generation file.
[0086] The image creation module is also used to generate container images corresponding to the upgraded application based on the modified image.
[0087] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0088] In one implementation, the image creation module is specifically used for:
[0089] Generate a container image for the first application based on the image generation file corresponding to the first application.
[0090] Generate a container image for the second application based on the image generation file corresponding to the second application.
[0091] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0092] Thirdly, embodiments of this application provide a server, including:
[0093] The processor, and the memory that is in communication with the processor;
[0094] Memory is used to store instructions that the computer executes;
[0095] The processor is used to execute computer execution instructions stored in memory to implement the image management method of the first aspect.
[0096] The server provided in this application embodiment can execute the technical solutions shown in the above method embodiments. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0097] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the image management method of the first aspect.
[0098] The computer-readable storage medium provided in this application embodiment can execute the technical solutions shown in the above method embodiments. Its implementation principle and beneficial effects are similar, and will not be repeated here.
[0099] Fifthly, embodiments of this application provide a computer program product, including a computer program, which, when executed by a processor, is used to implement the image management method of the first aspect.
[0100] The computer program product provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be repeated here. Attached Figure Description
[0101] To more clearly illustrate the technical solutions in the embodiments of this application 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 some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0102] Figure 1 This application provides a schematic diagram of the structure of a container image based on a hierarchical storage architecture.
[0103] Figure 2 A flowchart illustrating an embodiment of a mirror management method provided in this application;
[0104] Figure 3a A flowchart illustrating a second embodiment of a mirror management method provided in this application;
[0105] Figure 3b A schematic diagram of a directed acyclic graph for an application provided in an embodiment of this application;
[0106] Figure 3c A schematic diagram of a directed acyclic graph for another application provided in this application embodiment;
[0107] Figure 3d This is a schematic diagram illustrating how to obtain a multi-source directed acyclic graph according to an embodiment of this application.
[0108] Figure 3e A schematic diagram of a layer node diagram provided in an embodiment of this application;
[0109] Figure 3f A schematic diagram illustrating dependency analysis provided in an embodiment of this application;
[0110] Figure 3g A schematic diagram of the structure of a container image for another layered storage architecture provided in this application embodiment;
[0111] Figure 4a A flowchart illustrating a third embodiment of a mirror management method provided in this application;
[0112] Figure 4b A schematic diagram illustrating another method for analyzing dependencies, provided as an embodiment of this application;
[0113] Figure 4c This is a schematic diagram illustrating the generation of a modified layer node diagram, provided as an embodiment of this application.
[0114] Figure 4d A schematic diagram of the structure of a container image for another hierarchical storage architecture provided in this application embodiment;
[0115] Figure 5 This is a schematic diagram of the structure of a mirror management device provided in an embodiment of this application;
[0116] Figure 6 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Detailed Implementation
[0117] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments made by those skilled in the art under the guidance of these embodiments are within the scope of protection of this application.
[0118] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0119] Definitions:
[0120] An application (APP) is a computer program written for a specific user purpose. Applications can be categorized into different types based on their purpose or function; for example, applications can include e-commerce applications, social applications, office applications, and leisure and entertainment applications.
[0121] A container is a form of operating system virtualization, implemented through namespace isolation in the Linux kernel; essentially, it's a highly isolated process. A container is a running instance created from an image. This running instance can be a union file system including at least one read-only layer and one read-write layer. Containers run the software packages required by applications, achieving operating system-level virtualization, thus allowing applications to run in a relatively independent and isolated environment. This simplifies application deployment and enhances application portability and security.
[0122] An image is a union file system comprising multiple read-only layers. This union file system integrates different read-only layers into a single file system, providing a unified view and hiding the existence of multiple layers. From the user's perspective, the image appears as a single read-only file system. An image is a static representation of a container, and its relationship to a container is similar to that of a software package and a software process. Besides providing the programs, libraries, resources, and configuration files required for container runtime, an image also includes some configuration parameters prepared for runtime. Because an image contains the complete root file system of the operating system, its size is often enormous. Therefore, Docker was designed to fully utilize the Union File System (UnionFS) technology, designing images as a layered storage architecture. Images can be inherited through layering; various application container images can be created based on a base image. Figure 1 This is a schematic diagram of the structure of a container image based on a hierarchical storage architecture provided in an embodiment of this application. For example... Figure 1 As shown, in a tiered storage architecture, container images X, Y, and Z can share the same image layer A. Container images X and Y can share the same image layer B. Additionally, container image X can also include image layers G and D; container image Y can also include image layer E; and container image Z can also include image layers H, F, and C.
[0123] RPM (Red Hat Package Management): Proposed by Red Hat and adopted by many Linux distributions, it is a software management mechanism that uses a database record to install the required software onto the Linux system.
[0124] An RPM package is a pre-compiled binary software package that contains the software's source code, binary files, library files, configuration files, etc. RPM packages record dependency information, including the names and version numbers of the package and its dependencies, as well as the dependencies between the package and its dependencies (including direct and indirect dependencies). For example, an RPM package may require a dependency with a specific version number to run, and that dependency may in turn require its direct dependencies to function correctly. The RPM package manager can determine whether the dependencies of an RPM package exist during installation. If not, it automatically downloads and installs the dependencies before installing the RPM package. During the RPM package installation process, a set of scripts are executed in a specified order, including pre-installation scripts, installation scripts, upgrade scripts, and uninstallation scripts included in the RPM package. These scripts ensure that the RPM package is correctly installed on the system and that all necessary configuration files are correctly configured.
[0125] Dependency packages: One of the core principles of software design is modularity, where code for different functionalities is stored in separate files or classes, each representing a single-function module. Software packages embody this modularity by grouping single-function code into a package, which other modules can reference, improving code reusability and reducing maintenance costs. For an application's software package to function, other software packages are required as a foundation; these foundational packages are called dependency packages.
[0126] rpmorphan is a command-line tool that can analyze RPM packages to determine dependency information.
[0127] Version number: This is an identifier for a version of a software program, file, firmware, device driver, or even hardware. It is a unique number or set of numbers assigned to a specific version. As a new version is released, the version number increases. The version number allows users to know whether the application they are using is the latest version and what features and facilities it provides.
[0128] Directed Acyclic Graph: In mathematics, especially graph theory and computer science, a directed acyclic graph refers to a directed graph without loops.
[0129] DOT: DOT is a text-based graphics description language. It provides a simple way to describe graphics and can be understood by both humans and computer programs. DOT language files typically have the .gv or .dot file extension.
[0130] Dockerfile: A Dockerfile is a text file used to build an image. It contains the instructions for building a container. Docker can read the instructions in the Dockerfile to automatically build containers. Container images are created based on the Dockerfile. Each instruction creates an image layer, meaning that container images are made up of multiple layers.
[0131] Docker: Container technology used to enable the creation and use of Linux containers.
[0132] docker build: The docker build command is used to create container images using image generation files.
[0133] In related technologies, image management methods require generating a container image based on the application's software package and multiple other software packages (including packages the application package depends on and packages the application package does not depend on). During application runtime, the dependencies of the application's software package are analyzed, and packages that the application's software package does not depend on are trimmed. However, in these image management methods, there may be situations where the trimmed packages are depended on by packages from other applications, potentially leading to issues where the container image cannot be used correctly.
[0134] Based on the above-mentioned technical problems, the technical concept process of this application embodiment is as follows: According to the dependency information of multiple applications, the software package and at least one dependent package of each application are layered to obtain image layering information (which can represent the information of the software package and at least one dependent package of each application arranged in a layered manner according to the dependency relationship), and according to the image layering information, an image generation file corresponding to each application is generated to create a container image corresponding to each application.
[0135] The technical solution of this application will now be described in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0136] Figure 2 This is a flowchart illustrating an embodiment of a mirror management method provided in this application. See also... Figure 2 The method specifically includes the following steps:
[0137] S201: Obtain the software package for at least one application.
[0138] In this embodiment, when the server needs to run at least one application to provide a certain function, it needs to install the software package of at least one application on the server. The server can obtain the software package of at least one application. The software package records the application's dependency information.
[0139] It should be noted that the application's dependency information is used to represent the dependencies between the application's software package and at least one dependent package. These dependencies can include direct dependencies and indirect dependencies. Furthermore, the application's dependency information can include the name and version number of the software package, and the name and version number of at least one dependent package.
[0140] For example, the dependency information of the first application includes: the name and version number of package A, the name and version number of dependency package 1, the name and version number of dependency package 2, the name and version number of dependency package 3, the name and version number of dependency package 4, the name and version number of dependency package 6, the direct dependency between package A and dependency package 1, the direct dependency between package A and dependency package 2, the direct dependency between package A and dependency package 4, the direct dependency between dependency package 2 and dependency package 3, and the direct dependency between dependency package 4 and dependency package 6.
[0141] It should also be noted that the software package can be an RPM package or other forms of software packages, and this application embodiment does not limit this.
[0142] It should also be noted that in one implementation, the server can use rpmorphan (software) to analyze the software package and obtain the application's dependency information.
[0143] S202: Based on the dependency information, perform layering processing on the software package and at least one dependent package of each application to obtain image layering information.
[0144] In this embodiment, the server can perform layered processing on the software package and at least one dependent package of each application based on the dependency information to obtain image layering information.
[0145] When a server retrieves an application's software package:
[0146] The server can directly perform layering of the application's software packages and at least one dependent package based on the application's dependency information to obtain image layering information. It should be noted that image layering information can include one layer of information. This layer information includes the application's software packages and at least one dependent package.
[0147] When the server retrieves packages for multiple applications:
[0148] The server can merge dependency information from multiple applications to obtain overall dependency information. Based on this overall dependency information, the server can then layer each application's software package and at least one dependent package to obtain image layering information. It should be noted that the image layering information includes at least a common layer, a first sub-layer, and a second sub-layer. The common layer information includes at least one common dependent package; the first sub-layer information includes the first application's proprietary dependent package and the first application's software package; and the second sub-layer information includes the second application's proprietary dependent package and the second application's software package. Furthermore, it should be noted that the first and second sub-layer information are parallel; the first sub-layer information is based on the common layer information, and the second sub-layer information is based on the common layer information.
[0149] S203: Generate image generation files for each application based on the image layering information.
[0150] In this embodiment, the server can generate image files for each application based on the image layering information.
[0151] For example, when the server obtains the software packages of a first application and a second application, the image layering information includes common layer information, first sublayer information, and second sublayer information. The common layer information includes at least one common dependency package; the first sublayer information includes the application-specific dependency package and the software package of the first application; and the second sublayer information includes the application-specific dependency package and the software package of the second application. The server can generate an image file corresponding to the first application based on the common dependency package, the application-specific dependency package, and the software package of the first application. The server can also generate an image file corresponding to the second application based on the common dependency package, the application-specific dependency package, and the software package of the second application.
[0152] Specifically, the server can determine the software packages (and / or dependencies) in each image layer based on the image layering information. The server can then generate the corresponding application image build files layer by layer, from bottom to top (each layer using the previous layer as its base image). It should be noted that during the generation of each layer's image build file, the server generates the layer's image build file (Dockerfile) by adding the installation scripts for the layer's software packages (and / or dependencies) to each layer's image build file.
[0153] S204: Generate a container image for each application based on the image generation file corresponding to each application.
[0154] In this embodiment, the server can generate a container image for each application based on the image generation file of each application.
[0155] For example, if the server needs to generate a container image for a first application and a container image for a second application, the server can generate a container image for the first application based on the image generation file for the first application; the server can also generate a container image for the second application based on the image generation file for the second application.
[0156] Specifically, for each application, the server can generate the container image of that application layer by layer from the bottom up, based on the image generation file corresponding to that application. For example, the code is as follows:
[0157] $docker build-t${IMAGE_NAME}:latest-f${DOCKER_FILE_PATH}
[0158] It's important to note that the code above indicates that the `docker build` command is used to generate a container image based on the existing image. Here, `PATH` represents the context path of the generated container image, typically the directory containing the generated image files. `IMAGE_NAME` represents the name of the container image. `latest` indicates that it's marked as "latest".
[0159] The beneficial effects of this embodiment are as follows: Based on the dependency information recorded in the software package, this embodiment performs layered processing on the software package and at least one dependent package of each application to determine the image layering information, and then generates an image generation file for making a container image. In this way, the creation of the application's container image is optimized, so that the generated container image can be used normally.
[0160] The following describes, through Method Implementation Example 2, the process by which the server generates a container image for each application when the server obtains software packages for multiple applications.
[0161] Figure 3a This is a flowchart illustrating a second embodiment of a mirror management method provided in this application. See also... Figure 3a The method specifically includes the following steps:
[0162] S301: Obtain software packages for multiple applications.
[0163] In this embodiment, the server can obtain software packages for multiple applications.
[0164] Each application's software package records the application's dependency information, which indicates the dependency relationship between the application's software package and at least one dependent package.
[0165] S302: Merge the dependency information of multiple applications to obtain the overall dependency information.
[0166] In this embodiment, the server can merge the dependency information of multiple applications to obtain overall dependency information.
[0167] Specifically, the server can generate a directed acyclic graph (DAG) for each application based on its dependency information. In this DAG, the source node represents the application's software package; the dependency node represents the dependent package; the connection between the source and dependency nodes represents the dependency relationship (direct dependency) between the application's software package and its dependent packages; and the connection between dependency nodes represents the dependency relationship (direct dependency) between dependent packages.
[0168] For example, Figure 3b This is a schematic diagram of a directed acyclic graph for an application provided in an embodiment of this application. For example... Figure 3b As shown, in the directed acyclic graph corresponding to the first application, the source node represents software package A of the first application, and the dependency nodes represent dependency packages 1, 2, 3, 4, and 6, respectively. In the directed acyclic graph corresponding to the first application, the connection relationships represent the direct dependencies between software package A and dependency package 1, between software package A and dependency package 2, between dependency package 2 and dependency package 3, between software package A and dependency package 4, and between dependency package 4 and dependency package 6, respectively.
[0169] For example, Figure 3c This is a schematic diagram of a directed acyclic graph for another application provided in this application embodiment. For example... Figure 3c As shown, in the directed acyclic graph corresponding to the second application, the source node represents package B of the second application, and the dependency nodes represent dependency packages 1, 3, 5, and 6, respectively. In the directed acyclic graph corresponding to the second application, the connection relationships represent the direct dependencies between package B and dependency package 1, between package B and dependency package 3, between package B and dependency package 5, and between dependency package 5 and dependency package 6, respectively.
[0170] After generating directed acyclic graphs (DAGs) for multiple applications, the server can merge these DAGs to obtain a multi-source DAG. This multi-source DAG can represent overall dependency information.
[0171] The following describes the process of merging directed acyclic graphs (DAGs) from multiple applications on the server to obtain a multi-source DAG.
[0172] Specifically, the server can create a blank graph. This blank graph can be in DOT format.
[0173] For each application's directed acyclic graph (DAG), the server can update the blank graph by creating a corresponding source node if it determines that no source node in the blank graph is identical to a source node in the DAG. Similarly, the server can update the blank graph by creating a corresponding dependent node if it determines that no dependent node in the blank graph is identical to a dependent node in the DAG. Furthermore, the server can update the blank graph by creating a corresponding connection if it determines that no connection relationship in the blank graph is identical to a connection relationship in the DAG. The server can then determine that the updated blank graph is a multi-source DAG.
[0174] Figure 3d This is a schematic diagram illustrating how to obtain a multi-source directed acyclic graph according to an embodiment of this application. For example... Figure 3d As shown, the server can merge the directed acyclic graph corresponding to the first application and the directed acyclic graph corresponding to the second application to obtain a multi-source directed acyclic graph.
[0175] S303: Based on the overall dependency information, perform layering processing on the software packages and at least one dependent package of each application to obtain image layering information.
[0176] In this embodiment, the server can perform layered processing on the software packages and at least one dependent package of each application based on the overall dependency information to obtain image layering information.
[0177] Specifically, the server can perform layered processing on the multi-source directed acyclic graph based on the connection relationships of each node in each directed acyclic graph, generate a layered node graph, and determine the layered node graph as mirrored layered information.
[0178] The following section details the process by which the server performs layered processing on a multi-source directed acyclic graph (DAG) based on the connection relationships between nodes in each DAG, generating a layered node graph.
[0179] Specifically, the server can identify dependent nodes that connect to the same source node as dependent nodes at the same connection level. For each source node, the server can determine the connection level corresponding to the dependent nodes that are connected to the source node but not to other source nodes as the connection level corresponding to the source node. Based on the connection level corresponding to each source node and the connection level corresponding to each dependent node, the server performs layered processing on the multi-source directed acyclic graph to generate a layered node graph. For example, Figure 3e This is a schematic diagram of a layer node diagram provided in an embodiment of this application. Figure 3eAs shown, a layer node includes a source node representing package A, a dependency node representing dependency package 2, and a dependency node representing dependency package 4; a layer node includes a source node representing package B and a dependency node representing dependency package 5; and a layer node includes a dependency node representing dependency package 1, a dependency node representing dependency package 3, and a dependency node representing dependency package 6.
[0180] In one implementation, after generating the layer node graph, the server can adjust the graph based on the size of the package (or dependency package) represented by each source node (or dependency node) and a preset layer size. For example, if a layer node in the graph includes one source node and two dependency nodes, the server can split the layer node into two layers (one containing the source node and the other containing the two dependency nodes) based on the assumption that the package size represented by the source node is 200MB, the size of the two dependency packages represented by the two dependency nodes is 100MB each, and the preset layer size is 200MB. This adjustment process can then be used to define the adjusted layer node graph as the mirrored layer information.
[0181] The following section provides a detailed explanation of the process by which the server determines the source node to which each dependent node connects, using specific examples.
[0182] First, the server can analyze the dependencies between each source node and dependent node.
[0183] Figure 3f This is a schematic diagram illustrating the analysis of dependencies as provided in an embodiment of this application. Figure 3f As shown, the server can analyze the dependency relationships between each source node and dependent node based on the connection relationships between each node in each directed acyclic graph, and thus know:
[0184] Package A and package B both directly depend on dependency package 1; package A indirectly depends on dependency package 3 (package A directly depends on dependency package 2, and dependency package 2 directly depends on dependency package 3); package B directly depends on dependency package 3; package A indirectly depends on dependency package 6 (package A directly depends on dependency package 4, and dependency package 4 directly depends on dependency package 6); package B indirectly depends on dependency package 6 (package B directly depends on dependency package 5, and dependency package 5 directly depends on dependency package 6).
[0185] Based on the above, we can conclude that:
[0186] The dependency node corresponding to dependency package 1 is connected to the source nodes corresponding to package A and package B; the dependency node corresponding to dependency package 2 is connected to the source node corresponding to package A; the dependency node corresponding to dependency package 3 is connected to the source nodes corresponding to package A and package B; the dependency node corresponding to dependency package 4 is connected to the source node corresponding to package A; the dependency node corresponding to dependency package 5 is connected to the source node corresponding to package B; the dependency node corresponding to dependency package 6 is connected to the source nodes corresponding to package A and package B.
[0187] S304: Generate image generation files for each application based on the image layering information.
[0188] In this embodiment, the server can generate image files for each application based on the image layering information.
[0189] Specifically, for each application, the server can determine the layer node in the layer node graph that represents the source node of the application's software package, as well as the other layer nodes connected to that layer node. The server can then generate the corresponding image file for that application based on the layer node to which the source node of the application's software package belongs, and the other layer nodes connected to that layer node.
[0190] During the process of the server generating the image file corresponding to the application based on the layer node to which the source node of the application's software package belongs, and the other layer nodes connected to that layer node:
[0191] The server can identify the software packages (and / or dependencies) represented by the source nodes (and / or dependency nodes) in each layer, thus determining the software packages (and / or dependencies) in each image layer. Based on the base image and the software packages (and / or dependencies) in each image layer, the server generates the corresponding image files for the application layer by layer, from bottom to top (each layer uses the next lower layer as its base image). It should be noted that during the generation of each layer's image file, the server adds the installation scripts for the software packages (and / or dependencies) of that layer to the image file.
[0192] For example, the code for generating the image file corresponding to the first application is as follows:
[0193] ###common_layer_base_image
[0194] from baseimage
[0195] RUN rpm -ivh dependency1 dependency3 dependency6
[0196] ###app_a_image
[0197] from common_layer_base_image
[0198] RUN rpm -ivh dependency package2 dependency package4 package A
[0199] It should be noted that the above code means: using the base image as the base image, adding dependency package 1, dependency package 3, and dependency package 6 to the common base image layer (common_layer_base_image) to generate the common base image layer (common_layer_base_image). Using the common base image layer (common_layer_base_image) as the base image, adding dependency package 2, dependency package 4, and package A to the first application's image layer to generate the first application's image layer (app_a_image).
[0200] For example, the code for generating the Dockerfile corresponding to package B is as follows:
[0201] ###common_layer_base_image
[0202] from baseimage
[0203] RUN rpm -ivh dependency1 dependency3 dependency6
[0204] ###app_b_image
[0205] from common_layer_base_image
[0206] RUN rpm -ivh dependencies 5 packages B
[0207] It should be noted that the above code means: using `baseimage` as the base image, adding dependency package 1, dependency package 3, and dependency package 6 to the common base image layer (`common_layer_base_image`) to generate the common base image layer (`common_layer_base_image`). Using the common base image layer (`common_layer_base_image`) as the base image, adding dependency package 5 and package B to the second application's image layer (`app_b_image`) to generate the first application's image layer (`app_b_image`).
[0208] In addition, after the server generates the image file for each application, it can store the image file for each application.
[0209] S305: Generate a container image for each application based on the image generation file corresponding to each application.
[0210] In this embodiment, the server can generate a container image for each application based on the image generation file of each application.
[0211] It should be noted that when a server needs to deploy multiple applications simultaneously, the container images for these applications can be stored in a tiered storage architecture. For example, Figure 3g This is a schematic diagram of the structure of a container image of another hierarchical storage architecture provided in an embodiment of this application.
[0212] In addition, the server can save and process the container images corresponding to each application.
[0213] In one implementation, the server can save the image for each application as a separate file. For example, the code is as follows:
[0214] $docker save${IMAGE_NAME}:latest-o${IMAGE_PKG_NAME}#
[0215] It should be noted that the above code means: use the "docker save" command to save the container image "IMAGE_NAME" as a file.
[0216] In one implementation, when the server generates container images for multiple applications, it can save these container images as a single file. For example, the code is as follows:
[0217] $docker save${IMAGE_NAME_1}:latest${IMAGE_NAME_2}:latest…-o${PKG_NAME}#
[0218] It should be noted that the above code means: using the "docker save" command, save container image "IMAGE_NAME_1", container image "IMAGE_NAME_2", etc., into a single file.
[0219] The beneficial effects of this embodiment are as follows: Before generating the container image corresponding to an application, the dependency information of multiple applications is merged to obtain overall dependency information. Then, based on the overall dependency information, the software package and at least one dependent package of each application are layered to obtain image layering information. Based on the image layering information, an image generation file is generated. Finally, based on the image generation file corresponding to each application, a container image corresponding to each application is generated. Through the above method, the layered sharing capability of container images is realized, and the creation of multiple container images can be optimized simultaneously.
[0220] Figure 4a This is a flowchart illustrating a third embodiment of a mirror management method provided in this application. See also... Figure 4a The method specifically includes the following steps:
[0221] S401: Obtain the software package for the upgraded application.
[0222] In this embodiment, the server can obtain the upgraded application's software package, which contains the upgraded application's dependency information.
[0223] S402: If it is determined that the dependency information of the upgraded application is the same as that of the application before the upgrade, then obtain the image generation file corresponding to the application.
[0224] In this embodiment, after obtaining the upgraded application's software package, the server can compare the dependency information of the upgraded application with the dependency information of the application before the upgrade.
[0225] If the server determines that the dependency information of the upgraded application is the same as that of the application before the upgrade, it can retrieve the image generation file corresponding to the application stored on the server.
[0226] Additionally, it should be noted that if the server determines that the dependency information of the upgraded application differs from that of the application before the upgrade, it can merge the dependency information of the upgraded application and the dependency information of other related applications to obtain the changed overall dependency information. Based on the changed overall dependency information, the server can layer the software package and at least one dependent package of each application (the upgraded application and other related applications) to obtain changed image layering information. Based on the changed image layering information, the server can generate the image build file for the upgraded application, as well as the image build files for other applications. Based on the image build file for the upgraded application, the server can generate the container image for the upgraded application. Based on the image build files for other applications, the server can generate the container images for those other applications.
[0227] The following example illustrates the process by which the server generates container images for the upgraded application and other applications when the dependency information of the upgraded application differs from that of the application before the upgrade.
[0228] Figure 4b This is a schematic diagram illustrating another method for analyzing dependencies, provided as an embodiment of this application.
[0229] like Figure 4b As shown, before the upgrade, both package A and package B directly depend on dependency package 1; package A indirectly depends on dependency package 3 (package A directly depends on dependency package 2, and dependency package 2 directly depends on dependency package 3); package B directly depends on dependency package 3; package A indirectly depends on dependency package 6 (package A directly depends on dependency package 4, and dependency package 4 directly depends on dependency package 6); package B indirectly depends on dependency package 6 (package B directly depends on dependency package 5, and dependency package 5 directly depends on dependency package 6).
[0230] After the upgrade, both package A and package B directly depend on dependency package 1; package A indirectly depends on dependency package 3 (package A directly depends on dependency package 2, and dependency package 2 directly depends on dependency package 3); package B directly depends on dependency package 3; package A indirectly depends on dependency package 6 (package A directly depends on dependency package 5, and dependency package 5 directly depends on dependency package 6); package B indirectly depends on dependency package 6 (package B directly depends on dependency package 5, and dependency package 5 directly depends on dependency package 6).
[0231] The server can determine that the dependency information of the first application after the upgrade is different from the dependency information of the first application before the upgrade.
[0232] The server can merge the dependency information of the upgraded first application and the dependency information of the second application to obtain the changed overall dependency information. Based on the changed overall dependency information, the server can perform layering processing on the software packages and at least one dependent package of each application (the upgraded first application and the second application) to obtain the changed image layering information. Figure 4c This is a schematic diagram illustrating the generation of a modified layer node graph, as provided in an embodiment of this application. The modified multi-source directed acyclic graph represents the modified overall dependency information; the modified layer node graph represents the modified mirror layering information.
[0233] The server can generate image files for the upgraded application and other applications based on the changed image layering information. The server can also generate container images for the upgraded application based on the image files for the upgraded application. Furthermore, the server can generate container images for other applications based on their respective image files. It should be noted that the container images for the upgraded application and other applications can utilize a tiered storage architecture. For example, Figure 4d This is a schematic diagram of the structure of a container image for another layered storage architecture provided in an embodiment of this application. For example... Figure 4d As shown, if the server determines that the dependency information of the first application after the upgrade is different from that of the first application before the upgrade, the server can generate a container image corresponding to the first application and a container image corresponding to the second application.
[0234] S403: Based on the upgraded application's software package, modify the corresponding image generation file for the application and obtain the modified image generation file.
[0235] In this embodiment, after obtaining the image generation file corresponding to the application, the server can modify the image generation file corresponding to the application according to the upgraded application's software package to obtain the modified image generation file.
[0236] Specifically, the server can change the software package in the installation script of the top-level image generation file in the image generation file to the upgraded software package in order to obtain the modified image generation file.
[0237] S404: Generate the container image corresponding to the upgraded application based on the modified image generation file.
[0238] In this embodiment, the server can generate a container image corresponding to the upgraded application based on the modified image generation file.
[0239] In this embodiment, after obtaining the upgraded application's software package, if the server determines that the dependency information of the upgraded application is the same as that of the application before the upgrade, it obtains the corresponding image generation file. The server can modify the corresponding image generation file based on the upgraded application's software package to obtain a modified image generation file. The server can then generate a container image for the upgraded application based on the modified image generation file. Compared to related technologies, where, in the case of an application upgrade, the server needs to generate a container image for the upgraded application, re-analyze the dependency packages that the upgraded application depends on at runtime, and trim the container image, resulting in low efficiency in container image generation and optimization, this embodiment allows for reuse of the corresponding image generation file when the application's dependency information remains unchanged, thereby improving the efficiency of container image generation and optimization.
[0240] The following are embodiments of the apparatus of this application, which can be used to execute the embodiments of the method of this application. For details not disclosed in the embodiments of the apparatus of this application, please refer to the embodiments of the method of this application.
[0241] Figure 5 This is a schematic diagram of the structure of a mirror management device provided in an embodiment of this application, as shown below. Figure 5 As shown, the image management device 50 includes: a dependency resolution module 51, a dependency analysis module 52, an image generation file generation module 53, and an image creation module 54. Among them,
[0242] The dependency resolution module 51 is used to obtain the software packages of at least one application; wherein, the software packages of each application record the application's dependency information, which is used to represent the dependency relationship between the application's software packages and at least one dependent package;
[0243] The dependency analysis module 52 is used to perform layered processing on the software packages and at least one dependent package of each application according to the dependency relationship information to obtain image layering information. The image layering information is used to represent the information of the software packages and at least one dependent package of each application arranged in a layered manner according to the dependency relationship.
[0244] Image generation file generation module 53 is used to generate image generation files for each application based on image layering information;
[0245] The image creation module 54 is used to generate container images for each application based on the image generation file corresponding to each application.
[0246] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0247] In one implementation, dependency analysis module 52 is specifically used for:
[0248] When multiple application packages are obtained, the dependency information of the multiple applications is merged to obtain the overall dependency information;
[0249] Based on the overall dependency information, the software packages and at least one dependency package of each application are layered to obtain image layering information.
[0250] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0251] In one implementation, the image layering information includes at least common layer information, first sub-layer information, and second sub-layer information. The common layer information includes at least one common dependency package. The first sub-layer information includes the application-specific dependency package and the application's software package. The second sub-layer information includes the application-specific dependency package and the application's software package. The image generation file generation module 53 is specifically used for:
[0252] Based on the public dependency packages, the first application's proprietary dependency packages, and the first application's software packages, generate the image file corresponding to the first application;
[0253] Based on the public dependency packages, the second application's proprietary dependency packages, and the second application's software packages, generate the corresponding image file for the second application.
[0254] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0255] In one implementation, dependency analysis module 52 is specifically used for:
[0256] Based on the dependency information of each application, a directed acyclic graph is generated for each application. In the directed acyclic graph, the source node and the dependency node represent the application's software package and dependency package, respectively. The connection between dependency nodes represents the dependency relationship between dependency packages, and the connection between the source node and the dependency node represents the dependency relationship between the application's software package and dependency package.
[0257] The directed acyclic graphs of multiple applications are merged to obtain a multi-source directed acyclic graph, which is then used to determine the overall dependency information.
[0258] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0259] In one implementation, dependency analysis module 52 is specifically used for:
[0260] Based on the connection relationships of each node in each directed acyclic graph, the multi-source directed acyclic graph is processed into layers to generate layer node graphs, and the layer node graphs are determined as mirror layer information.
[0261] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0262] In one implementation, dependency analysis module 52 is specifically used for:
[0263] Dependent nodes that are connected to the same source node are identified as dependent nodes at the same connection level.
[0264] For each source node, the connection hierarchy corresponding to the dependent nodes that are connected to the source node but not connected to other source nodes is determined as the connection hierarchy corresponding to the source node.
[0265] Based on the connection hierarchy corresponding to each source node and the connection hierarchy corresponding to each dependent node, the multi-source directed acyclic graph is processed into layers to generate a layered node graph.
[0266] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0267] In one implementation, dependency analysis module 52 is specifically used for:
[0268] Create a blank drawing;
[0269] For each application's directed acyclic graph, if there is no source node in the blank graph that is the same as the source node in the directed acyclic graph, then the corresponding source node is created in the blank graph to update the blank graph.
[0270] If there is no dependent node in the blank graph that is the same as the dependent node in the directed acyclic graph, then the corresponding dependent node is created in the blank graph to update the blank graph.
[0271] If there is no connection in the blank graph that is the same as the connection relationship in the directed acyclic graph, then the corresponding connection relationship is created in the blank graph to update the blank graph;
[0272] The updated blank graph is identified as a multi-source directed acyclic graph.
[0273] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0274] In one implementation,
[0275] The dependency resolution module 51 is also used to obtain the software package of the upgraded application; wherein the software package of the upgraded application records the dependency information of the upgraded application.
[0276] The dependency resolution module 51 is also used to obtain the image generation file corresponding to the application if it is determined that the dependency information of the upgraded application is the same as that of the application before the upgrade.
[0277] The image generation file generation module 53 is also used to modify the image generation file corresponding to the application based on the upgraded application's software package, and obtain the modified image generation file.
[0278] The image creation module 54 is also used to generate container images corresponding to the upgraded application based on the modified image generation files.
[0279] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0280] In one implementation, the image creation module 54 is specifically used for:
[0281] Generate a container image for the first application based on the image generation file corresponding to the first application.
[0282] Generate a container image for the second application based on the image generation file corresponding to the second application.
[0283] The image management device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0284] Figure 6 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Figure 6 As shown, the server 60 includes a processor 61 and a memory 62; wherein the processor 61 is communicatively connected to the memory 62, and the memory 62 is used to store computer execution instructions; the processor 81 is configured to execute the technical solutions in the aforementioned method embodiments by executing the computer execution instructions stored in the memory 62.
[0285] Optionally, the memory 62 can be either standalone or integrated with the processor 61. Optionally, when the memory 62 is a device independent of the processor 61, the server 60 may further include a bus for connecting the aforementioned devices.
[0286] The processor is used to execute the technical solutions in the aforementioned method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0287] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the technical solutions provided in the aforementioned method embodiments.
[0288] This application also provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the technical solutions provided in the foregoing method embodiments.
[0289] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0290] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A mirror management method, characterized in that, include: Obtain at least one application's software package; wherein, each application's software package records the application's dependency information, the dependency information being used to indicate the dependency relationship between the application's software package and at least one dependent package; When multiple application packages are obtained, the dependency information of the multiple applications is merged to obtain overall dependency information; Based on the overall dependency information, the software packages and at least one dependency package of each application are layered to obtain image layering information; the image layering information includes at least common layer information, first sub-layer information and second sub-layer information; the common layer information includes at least one common dependency package, the first sub-layer information includes the proprietary dependency package of the first application and the software package of the first application, and the second sub-layer information includes the proprietary dependency package of the second application and the software package of the second application; The image layering information is used to represent the information of each application's software package and at least one of its dependent packages arranged in a layered manner according to the dependency relationship; Based on the public dependency package, the application's proprietary dependency package, and the application's software package, generate the image file corresponding to the first application; Based on the public dependency package, the application's proprietary dependency package, and the application's software package, generate the image file corresponding to the application. Generate a container image for each application based on the image generation file corresponding to each application.
2. The mirror management method according to claim 1, characterized in that, The process of merging the dependency information of multiple applications to obtain overall dependency information includes: Based on the dependency information of each application, a directed acyclic graph is generated for each application; wherein, in the directed acyclic graph, the source node and the dependent node represent the application's software package and dependent package, respectively, the connection relationship between dependent nodes represents the dependency relationship between dependent packages, and the connection relationship between the source node and the dependent node represents the dependency relationship between the application's software package and dependent package. The directed acyclic graphs of multiple applications are merged to obtain a multi-source directed acyclic graph, and the multi-source directed acyclic graph is determined as the overall dependency information.
3. The mirror management method according to claim 2, characterized in that, The step of performing layered processing on the software packages of each application and at least one of the dependent packages based on the overall dependency information to obtain the image layering information includes: Based on the connection relationships of each node in each of the directed acyclic graphs, the multi-source directed acyclic graphs are layered to generate layer node graphs, and the layer node graphs are determined as the mirror layering information.
4. The mirror management method according to claim 3, characterized in that, The step of performing layered processing on the multi-source directed acyclic graph to generate a layered node graph based on the connection relationships of each node in each directed acyclic graph includes: Dependent nodes that are connected to the same source node are identified as dependent nodes at the same connection level. For each source node, the connection hierarchy corresponding to the dependent nodes that are connected to the source node but not connected to other source nodes is determined as the connection hierarchy corresponding to the source node. Based on the connection hierarchy corresponding to each source node and the connection hierarchy corresponding to each dependent node, the multi-source directed acyclic graph is layered to generate the layer node graph.
5. The mirror management method according to claim 2, characterized in that, The process of merging directed acyclic graphs from multiple applications to obtain a multi-source directed acyclic graph includes: Create a blank drawing; For each application's directed acyclic graph, if there is no source node in the blank graph that is the same as the source node in the directed acyclic graph, then a corresponding source node is created in the blank graph to update the blank graph. If there is no dependent node in the blank graph that is the same as the dependent node in the directed acyclic graph, then the corresponding dependent node is created in the blank graph to update the blank graph. If there is no connection relationship in the blank graph that is the same as the connection relationship in the directed acyclic graph, then a corresponding connection relationship is created in the blank graph to update the blank graph; The updated blank graph is identified as the multi-source directed acyclic graph.
6. The mirror management method according to claim 1, characterized in that, Also includes: Obtain the software package of the upgraded application; wherein the software package of the upgraded application records the dependency information of the upgraded application; If it is determined that the dependency information of the upgraded application is the same as that of the application before the upgrade, then the image generation file corresponding to the application is obtained. Based on the upgraded application's software package, the corresponding image generation file of the application is modified to obtain the modified image generation file; Based on the modified image generation file, generate the container image corresponding to the upgraded application.
7. The mirror management method according to claim 1, characterized in that, The step of generating a container image for each application based on the image generation file corresponding to each application includes: Generate a container image corresponding to the first application based on the image generation file corresponding to the first application. Generate a container image for the second application based on the image generation file corresponding to the second application.
8. A server, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory is used to store computer-executed instructions; The processor is used to execute computer execution instructions stored in the memory to implement the image management method according to claims 1-7.
Citation Information
Patent Citations
Application mirror image construction method and device, electronic equipment and storage medium
CN112256282A
Container mirror image library safety evaluation system and method based on dependency relationship
CN113111353A
Container mirror image file intelligent generation method and device, equipment and storage medium
CN113342359A