Mirror image generation method and device and storage medium
By obtaining blank images, module files and recipe files, calling target module files and installing components or dependency libraries in blank images, the existing Docker image generation methods are solved, and the simplified image construction process and efficient image generation are achieved.
Patent Information
- Application Number
- CN202311746364.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-18
- Publication Date
- 2025-06-20
AI Technical Summary
The existing Docker image generation method has problems such as slow network download speed, limited image selection, and complex and cumbersome construction process.
By obtaining blank images, module files and recipe files, the module files contain installation information of components or dependency libraries. The recipe files specify the path of the target module file, call the target module file and install the components or dependency libraries in the blank image based on the installation information to generate the target image.
Simplifies the process of building basic images, allowing users to select and install required components and dependency libraries by themselves, avoids the complexity of using busybox and Dockerfile tools, and improves the flexibility and efficiency of image generation.
Smart Images

Figure CN120179338A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technologies, and particularly to a method and apparatus for generating an image and a storage medium. Background Art
[0002] Docker technology is a lightweight container technology. In Docker, there are three important concepts, namely image, container, and Docker hub. An image is an image file of a system and is a read-only file. This image file can only be packaged by docker and is used to provide an application environment for an application program. A container is an instance of an image, that is, equivalent to an image + a writable layer, and is a running instance of the image. A Docker hub is an official repository for storing image files. The relationship between an image and a container can be analogized to the International Organization for Standardization (ISO) image and an operating system. As Figure 1 shown, an image file is composed of a base image and multiple writable layers. After deploying the image file on docker, a runnable container based on the image can be obtained, similar to obtaining a runnable Windows / Linux system after installing an ISO image file on a USB flash drive.
[0003] The use of Docker technology is all based on operating on Docker images, and all Docker images are obtained by packaging from base images. There are two ways to obtain a base image. One is network download: accessing and logging in to the Docker Hub repository to obtain a base image from the Docker Hub repository. However, accessing the Docker Hub repository requires remote access to an overseas website, the network speed is slow and it may even be inaccessible, and the Docker Hub repository can only provide base images of common systems, and the selection of base images is greatly limited by the images it provides. The other is to build it manually through the tool busybox and Dockerfile: first use busybox to create a root file system rootfs on a physical machine system, then write a Dockerfile, and then, based on the blank image Scratch, add a compressed package of the root file system rootfs to the blank image and build the base image of the physical machine according to the Dockerfile. This method requires more building tools, the building process is complex, and the busybox tool used has relatively high requirements for the experience of users. Secondly, this method must be based on a running physical machine system to package the root file system, which means that for each base image produced, the physical machine system must be installed, and busybox must be installed and then operated, and the operation is cumbersome. Summary of the Invention
[0004] In view of the above problems, embodiments of the present invention are provided to provide a mirror generation method, apparatus, and storage medium that overcome the above problems or at least partially solve the above problems.
[0005] In a first aspect, embodiments of the present invention disclose a mirror generation method, including:
[0006] Obtain a blank mirror;
[0007] Obtain a plurality of module files, each of the module files including installation information of components or dependency libraries;
[0008] Obtain a recipe file, the recipe file including the path of the target module file;
[0009] According to the path of the target module file, call the target module file, and install the components or dependency libraries in the blank mirror according to the installation information in the target module file to generate a target mirror.
[0010] Optionally, one of the module files includes installation information of one component or one dependency library; the number of the recipe files is one; the target module file is at least one of the plurality of module files.
[0011] Optionally, the method further includes:
[0012] Detect a first modification operation of the user on the module file;
[0013] Modify the module file according to the first modification operation.
[0014] Optionally, the installation information includes the acquisition path of the installation package of the component or dependency library, the acquisition path of the installation script, and the installation path pointing to the blank mirror. Then, installing the component or dependency library in the blank mirror according to the installation information in the target module file includes:
[0015] According to the acquisition path of the installation package of the component or dependency library in the target module file, obtain the installation package of the component or dependency library;
[0016] According to the acquisition path of the installation script in the target module file, obtain the installation script;
[0017] Execute the installation script, run the installation package, and install the component or dependency library in the blank mirror pointed to by the installation path.
[0018] Optionally, the method further includes:
[0019] Containerize the target image to obtain a target container;
[0020] Obtain verification information of components or dependent libraries in the target container;
[0021] When running components or dependent libraries in the target container, verify user permissions according to the verification information;
[0022] After the verification passes, run the components or dependent libraries in the target container.
[0023] Optionally, the method further includes:
[0024] When detecting that the user performs a second modification operation on the verification information, modify the verification information according to the second modification operation.
[0025] Optionally, the verification information includes at least one of user information and password information. Then, verifying user permissions according to the verification information includes:
[0026] Verify user permissions according to the user information and / or password information corresponding to the components or dependent libraries in the target container.
[0027] Optionally, the number of the target module files is multiple, and the recipe file further includes the call order of the multiple target module files. Then, calling the target module files according to the path of the target module files, and installing the components or dependent libraries in the blank image according to the installation information in the target module files to generate a target image includes:
[0028] According to the call order of the multiple target module files, sequentially call the multiple target module files according to the paths of the multiple target module files, and install the components or dependent libraries in the blank image according to the installation information in each target module file to generate a target image.
[0029] Optionally, the recipe file further includes the output form and output path of the target image, and the output form is used to specify the generation format of the target image. Then, generating the target image includes:
[0030] Generate a target image in a specified format according to the output form, and save the target image under the output path.
[0031] Optionally, the recipe file includes a blank image creation instruction. Then, obtaining the blank image includes:
[0032] Execute the blank image creation instruction to obtain a blank image.
[0033] Optionally, the recipe file further includes an operating system type, which is used to specify the operating environment after the target image is containerized. The method further includes:
[0034] Deploy an operating system according to the operating system type;
[0035] Containerize the target image to run in the operating system.
[0036] In a second aspect, an embodiment of the present invention discloses an image generation device, including: a processor and a memory. A computer program is stored in the memory. When the processor executes the computer program, the steps of the above image generation method are executed.
[0037] In a third aspect, an embodiment of the present invention discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above image generation method are implemented.
[0038] The embodiments of the present invention have the following advantages:
[0039] Obtain a blank image, module files, and a recipe file respectively. Among them, there are multiple module files, and each module file includes installation information of components or dependent libraries. The recipe file includes the path of the target module file. Then, according to the path of the target module file in the recipe file, the target module file is called, and according to the installation information in the target module file, components or dependent libraries are installed in the blank image to generate a target image. Through the embodiments of the present invention, users only need to write module files and recipe files, and can build the basic image required by users on the basis of the blank image according to the module files and recipe files. The basic image construction process is simple and easy to operate. Description of the Drawings
[0040] Figure 1 is a schematic diagram of the relationship between a Docker image and a container provided by the present invention;
[0041] Figure 2 is a flowchart of the steps of an image generation method provided by an embodiment of the present invention;
[0042] Figure 3 is a flowchart of the steps of another image generation method provided by an embodiment of the present invention;
[0043] Figure 4 is a flowchart of an image generation provided by an embodiment of the present invention;
[0044] Figure 5 is a schematic diagram of an image construction provided by an embodiment of the present invention;
[0045] Figure 6 It is a structural block diagram of an image generation device provided by an embodiment of the present invention. Specific embodiments
[0046] To make the above objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0047] When downloading the base image by logging in to the Docker Hub website, there are the following two problems: (1) Access to the Docker Hub repository requires remote access to an overseas website, and the network speed is slow or even impossible to access. Currently, to access and download Docker Hub, it is necessary to configure the domestic image source address; (2) The Docker Hub repository can only provide base images of common systems, and the selection of base images is greatly limited by the images it provides. It is impossible to directly download the base image of a dedicated system customized by an enterprise from the Docker Hub repository.
[0048] When building the base image through busybox and Dockerfile tools, there are the following three problems: (1) There are many tools involved in building the base image, and the tool versions must correspond, and the steps are relatively cumbersome. It is easy to make mistakes during the building process, resulting in the failure of image building; (2) During the building process, it is necessary to first package the root file system based on a running physical machine system, which means that for each base image to be made, the physical machine system must be installed, and busybox must be installed before proceeding with the operation, and the operation is cumbersome. Moreover, the root file system contains various components and dependencies. If you want to modify the components and dependencies in the root file system, you must first make the base image and run the base image in a containerized manner before you can modify the components and dependencies in the root file system; (3) The busybox tool used to build the base image requires relatively high experience for users.
[0049] One of the core concepts of the embodiments of the present invention is to separately obtain a blank image, a module file, and a recipe file, where the module file includes the installation information of components or dependency libraries; the recipe file includes the path of the target module file; then, according to the path of the target module file in the recipe file, the target module file is called, and according to the installation information in the target module file, the components or dependency libraries are installed in the blank image, so that the target image can be obtained. This method can build the required base image according to user needs. Moreover, the building process does not require the use of tools such as busybox and Dockerfile, nor does it require packaging the root file system based on a running physical machine system. The building process mainly requires a module file and a recipe file, and these two files can be written by the user, and the writing process is simple.
[0050] Refer toFigure 2 , which shows the step flowchart of a mirror generation method provided by an embodiment of the present invention. The method can be applied to any kind of electronic device, and the electronic device can include electronic devices such as a computer, a server, a tablet computer, etc. The embodiment of the present invention does not impose any restrictions on the specific type of the electronic device. The method can specifically include the following steps:
[0051] Step 101, obtain a blank mirror.
[0052] A blank mirror is a blank editable mirror, which is equivalent to a blank layer. Based on the blank mirror, a Docker - runnable mirror can be made. The blank mirror can be obtained through the inherit scratch instruction, and this instruction can reference the blank mirror scratch provided by Docker official as the basis for building a Docker mirror.
[0053] Step 102, obtain multiple module files, and each module file respectively includes the installation information of components or dependent libraries.
[0054] A component is equivalent to an application program. Components can include: database component MySQL (Relational Database Management System), remote control component VNC (Virtual Network Console), etc. Dependent library: Usually an RPM (RedHat Package Manager) package, which cannot run by itself, but may be called when other components are running. It is equivalent to a dynamic library. Dependent libraries can include driver dependency pciaccess (a kind of Peripheral Component Interconnect library).
[0055] Module files are files compiled by users, and the number of module files can be multiple. A module file can include the installation information of one component or one dependent library. For example, module file 1 includes the installation information of component A, and module file 2 includes the installation information of dependent library A.
[0056] The installation information can include the acquisition path of the installation package of the component or dependent library, and the installation path of the installation package of the component or dependent library, etc. For example, module file 1 includes the installation information of component A, and the installation information includes the acquisition path of the installation package of component A and the installation path of the installation package of component A.
[0057] Step 103, obtain a recipe file, and the recipe file includes the path of the target module file.
[0058] The recipe file is a file compiled by the user and is mainly used for the management of module files. Therefore, the number of recipe files can be one. The target module file can be at least one module file among multiple module files. The recipe file can include the names and paths of at least one target module file specified by the user. For example, when the module files include Module File 1, Module File 2, Module File 3, Module File 4, and Module File 5, and the user only needs the components or dependent libraries in Module File 1 and Module File 2 to build the base image, Module File 1 and Module File 2 can be used as the target module files, and the names and paths of the target module files are written into the recipe file.
[0059] Step 104: Call the target module file according to the path of the target module file, and install the components or dependent libraries in the blank image according to the installation information in the target module file to generate the target image.
[0060] After obtaining the recipe file, the target module file can be called according to the path of the target module file in the recipe file, and the components or dependent libraries recorded in the target module file can be installed in the blank image according to the installation information in the target module file to generate the target image. The target image can be used as the base image.
[0061] In the embodiment of the present invention, a blank image, module files, and a recipe file are obtained. The module files include multiple ones, and each module file respectively includes the installation information of components or dependent libraries. The recipe file includes the paths of the target module files. According to the paths of the target module files in the recipe file, the target module files are called, and the components or dependent libraries are installed in the blank image according to the installation information in the target module files to generate the target image. First, for the target image, that is, the base image, there is no need to access an overseas website to log in to the Docker Hub repository and download it from the Docker Hub repository. Therefore, the problem that the base image cannot be obtained due to the inability to access the overseas website will not occur. Second, the process of generating the base image does not require the use of the busybox and Dockerfile tools. The user only needs to write the module files and the recipe file. The use requirements of the busybox and Dockerfile tools are relatively high. Compared with learning to use the busybox and Dockerfile tools to build the base image, in the embodiment of the present invention, the user only needs to determine the components and dependent libraries required for building the base image, write the installation information of the required components and dependent libraries into the module file, and then write the path of the module file into the recipe file. The writing of the installation information in the module file and the writing of the module file path in the recipe file are simple operations. Finally, the user can select the components and dependent libraries required for building the base image according to the needs. Therefore, the generated base image better meets the user's needs.
[0062] In one embodiment, the mirror generation method further includes: detecting a first modification operation of the user on the module file; modifying the module file according to the first modification operation. The user can perform the first modification operation on the module file according to requirements, or can first determine the target module file and then perform the first modification operation on the target module file to make the module file or the target module file more in line with the user's requirements. The first modification operation may include modifying the name of the module file, the path of the module file, or the installation information of components or dependent libraries in the module file, etc. When the electronic device detects the first modification operation of the user on the module file, it can modify the module file according to the first modification operation.
[0063] Referring to Figure 3 , a flowchart of steps of another mirror generation method provided by an embodiment of the present invention is shown. The method may specifically include the following steps:
[0064] Step 201, obtain a blank mirror.
[0065] Step 202, obtain a plurality of module files. Each module file respectively includes installation information of components or dependent libraries. The installation information includes the acquisition path of the installation package of the components or dependent libraries, the acquisition path of the installation script, and the installation path pointing to the blank mirror.
[0066] One module file includes the installation information of one component or one dependent library. The installation information may include the acquisition path of the installation script, the acquisition path of the installation package of the components or dependent libraries, and the installation path pointing to the blank mirror. Among them, the installation script can be written in other files except the recipe file and the module file, and the installation script can be called through the acquisition path of the installation script to execute the installation program.
[0067] Step 203, obtain a recipe file. The recipe file includes the path of the target module file.
[0068] The user can determine the components and dependent libraries required for building the base mirror according to the construction requirements of the base mirror, and select the target module file from the module files according to the required components and dependent libraries. After determining the target module file, the user can directly use the target module file or modify the target module file, such as modifying the name of the target module file, the path of the target module file, the acquisition path of the installation package of the components or dependent libraries in the target module file, the acquisition path of the installation script, and so on.
[0069] Before generating the target image, users can add, delete, or modify the target module file. Just note that if the target module file is added, deleted, or modified, the relevant information of the target module file recorded in the recipe file needs to be modified accordingly. For example, if the user modifies the path of the target module file, the path of the target module file recorded in the recipe file needs to be modified accordingly.
[0070] Step 204, call the target module file according to the path of the target module file.
[0071] Step 205, obtain the installation package of the component or dependency library according to the acquisition path of the installation package of the component or dependency library in the target module file.
[0072] Step 206, obtain the installation script according to the acquisition path of the installation script in the target module file.
[0073] Step 207, execute the installation script, run the installation package, and install the component or dependency library in the blank image pointed to by the installation path.
[0074] After obtaining the installation package, installation script, and installation path of the component or dependency library in the target module file, the installation script can be executed to run the installation package, and the installation package of the component or dependency library can be installed in the blank image pointed to by the installation path, that is, installed in the blank image to generate the target image.
[0075] The embodiments of the present invention can achieve:
[0076] 1) Directly build the Docker base image through the module file and the recipe file, rather than being limited to the base images provided by the official Docker Hub repository.
[0077] 2) If a module file includes the installation information of a component or a dependency, the components or dependency libraries required for the Docker base image can be conveniently added, deleted, or modified by adding, deleting, or modifying the module file, ensuring that the constructed Docker base image can be completed in one step, and there is no need to add dependencies additionally after the construction is completed.
[0078] 3) Building the Docker base image based on the module file and the recipe file can avoid the method of using the busybox tool to generate the root file, simplifying the image making process.
[0079] 4) The composition of the image is clear at a glance. The component or dependency library resources used in the constructed Docker base image can be directly obtained from the official website, so as to avoid using the Docker base image provided by others that installs insecure components or code. Therefore, the security can be improved to a certain extent, and the Docker base image with unknown sources can be avoided.
[0080] In one embodiment, after generating the target image, the method may further include: containerizing the target image to obtain a target container; obtaining verification information of components or dependent libraries in the target container; when running the components or dependent libraries in the target container, verifying the user permissions according to the verification information; and when the verification passes, running the components or dependent libraries in the target container.
[0081] The installation packages of the components and dependent libraries may include configuration files, and the verification information may be stored in the configuration files. Therefore, the verification information of the components and dependent libraries can be obtained from the installation packages of the components and dependent libraries. Then, when generating the target image, containerizing the target image to obtain a target container, and running the components or dependent libraries in the target container, the user permissions can be verified according to the verification information of the components or dependent libraries; when the verification passes, the components or dependent libraries in the target container can be run according to the user permissions determined by the verification.
[0082] In one embodiment, before generating the target image, the user can modify the verification information of the components or dependent libraries for building the target image. Then, the image generation method may further include: when detecting a second modification operation on the verification information by the user, modifying the verification information according to the second modification operation.
[0083] The target module file may include the acquisition path of the configuration file of the component or dependent library. Generally, the configuration file of the component or dependent library is stored in the installation package of the component or dependent library. Therefore, the acquisition path of the configuration file of the component or dependent library may be the storage path of the configuration file of the component or dependent library in the installation package. The user can access the configuration file according to the acquisition path of the configuration file in the target module file and view or perform a second modification operation on the verification information in the configuration file. The second modification operation may include modifying the username and password in the verification information.
[0084] If the user modifies the verification information in the configuration file in the installation package of the component or dependent library corresponding to the target module file, then when generating the target image, containerizing the target image to obtain a target container, and running the components or dependent libraries in the target container, the verification information modified by the user is obtained from the installation package of the component or dependent library, and then the user permissions can be verified according to the modified verification information.
[0085] In one embodiment, the verification information includes at least one of user information and password information. Then, the step of verifying the user permissions according to the verification information may include: verifying the user permissions according to the user information and / or password information corresponding to the components or dependent libraries in the target container. The user information may include a username, and the password information may include a password. The user permissions may be verified according to the user information and / or password information corresponding to the components or dependent libraries in the target container. If the verification is passed, the components and dependent libraries in the target container may run according to the user permissions.
[0086] In one embodiment, the number of target module files may be multiple, and the recipe file may further include the call order of the multiple target module files. Then, step 104 may specifically include:
[0087] According to the call order of the multiple target module files, sequentially call the multiple target module files according to the paths of the multiple target module files, and install the components or dependent libraries in the blank image according to the installation information in the multiple target module files to generate a target image.
[0088] The recipe file includes the names and paths of the target module files, and the individual target module files can be written in a certain order. After obtaining the recipe file, the target module files can be called sequentially according to the writing order of the individual target module files, and the components or dependent libraries can be installed in the blank image according to the installation information in the target module files.
[0089] Among them, the writing order of the target module files is determined by the user. For example, module file 1 includes the installation information of component A, and module file 2 includes the installation information of dependent library B, and the operation of dependent library B depends on component A. Then, when the user writes the recipe file, module file 1 can be ranked before module file 2.
[0090] In one embodiment, the recipe file may further include the output form and output path of the target image. The output form is used to specify the generation format of the target image. The step of generating the target image in step 104 may specifically include: generating a target image in a specified format according to the output form in the recipe file, and saving the target image under the output path. The output form may be a form specified by the user, such as output as a tar package, and the output path may be a path specified by the user.
[0091] In one embodiment, the recipe file further includes a blank image creation instruction. Step 104 may specifically include: executing the blank image creation instruction to obtain a blank image. The blank image creation instruction can be written in the recipe file. After obtaining the recipe file, a blank image can be created according to the blank image creation instruction in the recipe file.
[0092] In one embodiment, the recipe file may further include the operating system type, which is used to specify the operating environment after the target image is containerized. The image generation method may further include: deploying the operating system according to the operating system type; and containerizing the target image to run in the operating system. The user can determine in advance the operating system type of the Docker base image to be built, and the operating system type may be a Linux system (a Unix-like operating system), a RedHat system, a CentOs system (Community Enterprise Operating System), an Ubuntu system (a Linux distribution operating system mainly for desktop applications), etc. After determining the operating system type, the components and dependent libraries that can run on this operating system type and meet the user's functional requirements can be determined. After determining the components and dependent libraries, the module file and the recipe file are written. Then, after the target image is built according to the recipe file, the target image can be containerized and run in the corresponding operating system.
[0093] Referring to Figure 4 , a flowchart of an image generation provided by an embodiment of the present invention is shown. The user selects the operating system type of the Docker base image to be built and obtains a blank image scratch. The user determines the components and dependent libraries that can run on this operating system type and have the required functions, and writes module files 1 to n according to the target components and target dependent libraries. Among them, a module file includes the configuration information of a component or a dependent library. The configuration information for a component may include: the name of the component, the acquisition path of the component installation package, the version number of the component, the acquisition path of the configuration file (config file) in the component installation package, the path of the installation script, the installation path of the component, etc.
[0094] For example, if the component is the mysql component, the module file of the mysql component can be written in the following format:
[0095] name=mysql / / Declare the component or dependency name
[0096] version=3.57 / / Declare the component or dependency version
[0097] src=https: / / xxx.com / file: / / gnome.pcg / / The network resource path or local resource path of the component, where the path after file can be an absolute path or a relative path to the lower layer of the current path
[0098] cfg=file: / / gnome.cfg / / The acquisition path of the configuration file in the component installation package
[0099] / / The following is the writing of installation scripts for different components or dependencies
[0100] do_install{
[0101] chmod 755 ${D} / path / / The path of the installation script, giving the script at this path an execution permission
[0102] make ${D} / path / / The path of the installation script, the installation script is written in another file other than the module file and the recipe file
[0103] make install ${D} / path / / The installation path, the installation path points to the blank image
[0104] }
[0105] After writing the module file of the mysql component, the user can modify the configuration file in the component installation package according to cfg=file: / / gnome.cfg / in the module file. For example, set the default user to mysql and the default password to 888888. If this component does not require modification of the configuration file, this step can be skipped.
[0106] After determining the configuration file, the user can write the specific content of the installation script.
[0107] The configuration information for the dependent library is similar to that for the component. The configuration information for the dependent library can include: the name of the dependent library, the acquisition path of the dependent library installation package, the version number of the dependent library, the path of the configuration file in the dependent library installation package, the path of the installation script, the installation path of the dependent library, etc.
[0108] After writing the module file, the recipe file can be written. The recipe file can be as shown in Table 1, including the recipe file name, the operating system type, the blank image creation instruction, the names and paths of each target module file, the output form and the output path.
[0109] Table 1 Elements of the recipe file
[0110] Formulation file description Blank image inherit scratch System type linux Module file 1 Path of module file 1 Module file 2 Path of module file 2 … … Module file n Path of module file n Output format tar Output path out_dir
[0111] According to the names and paths of module files 1 to n in the recipe file, module files 1 to n can be called in sequence, and the components or dependent libraries in module files 1 to n are installed in the blank image, and a tar package of the base image is generated under the output path. This tar package can be uploaded to the official Docker Hub repository; it can also be directly copied to the Docker engine that needs to run, and then execute the following statement: docker import filename.tar imagename:imagelabel to import the base image into Docker and deploy it.
[0112] Refer to Figure 5 , which shows a schematic diagram of image construction provided by an embodiment of the present invention. The blank image scratch + module file + recipe file can be used to construct a Docker base image. The blank image scratch is equivalent to a base, and module files can be arbitrarily built on the base. The module files include configuration information of components or dependent libraries, and then the module files are managed through the recipe file. Then, a user-defined Docker base image can be constructed based on the blank image scratch + module file + recipe file.
[0113] It should be noted that for the method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the embodiments of the present invention are not limited by the described action sequence, because according to the embodiments of the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential for the embodiments of the present invention.
[0114] Refer to Figure 6 , which shows a structural block diagram of an image generation device provided by an embodiment of the present invention. The device includes: a processor and a memory. A computer program is stored in the memory. When the processor executes the computer program, it performs:
[0115] Obtain a blank image;
[0116] Obtain at least one module file, and each of the module files includes installation information of components or dependent libraries;
[0117] Obtain a recipe file, and the recipe file includes the path of the target module file;
[0118] According to the path of the target module file, call the target module file, and install the components or dependent libraries in the blank image according to the installation information in the target module file to generate a target image.
[0119] Optionally, the number of the module files is multiple, and one of the module files includes the installation information of one component or the installation information of one dependency library; the number of the recipe files is one; the target module file is at least one of the multiple module files.
[0120] Optionally, when the processor executes the computer program, it performs: detecting a first modification operation of the user on the module file; modifying the module file according to the first modification operation.
[0121] Optionally, the installation information includes the acquisition path of the installation package of the component or the dependency library, the acquisition path of the installation script, and the installation path pointing to the blank image. When the processor executes the computer program, it performs: acquiring the installation package of the component or the dependency library according to the acquisition path of the installation package of the component or the dependency library in the target module file; acquiring the installation script according to the acquisition path of the installation script in the target module file; executing the installation script, running the installation package, and installing the component or the dependency library in the blank image pointed to by the installation path.
[0122] Optionally, when the processor executes the computer program, it performs: containerizing the target image to obtain a target container; acquiring the verification information of the components or dependency libraries in the target container; when running the components or dependency libraries in the target container, verifying the user permissions according to the verification information; and when the verification passes, running the components or dependency libraries in the target container.
[0123] Optionally, when the processor executes the computer program, it performs: when detecting a second modification operation of the user on the verification information, modifying the verification information according to the second modification operation.
[0124] Optionally, the verification information includes at least one of user information and password information. Then, when the processor executes the computer program, it performs: verifying the user permissions according to the user information and / or password information corresponding to the components or dependency libraries in the target container.
[0125] Optionally, the number of the target module files is multiple, and the recipe file further includes the call order of the multiple target module files. Then, when the processor executes the computer program, it performs: according to the call order of the multiple target module files, successively calling the multiple target module files according to the paths of the multiple target module files, and installing the components or dependency libraries in the blank image according to the installation information in each target module file to generate a target image.
[0126] Optionally, the recipe file further includes the output format and output path of the target image. The output format is used to specify the generation format of the target image. When the processor executes the computer program, it performs the following: generating a target image in the specified format according to the output format, and saving the target image under the output path.
[0127] Optionally, the recipe file includes a blank image creation instruction. When the processor executes the computer program, it performs the following: executing the blank image creation instruction to obtain a blank image.
[0128] Optionally, the recipe file further includes the operating system type, which is used to specify the operating environment after the target image is containerized. When the processor executes the computer program, it performs the following: deploying an operating system according to the operating system type; containerizing the target image to run in the operating system.
[0129] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For the relevant parts, please refer to the partial description of the method embodiment.
[0130] 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, it implements each process of the above-mentioned mirror generation method embodiment and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.
[0131] Each embodiment in this specification is described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other.
[0132] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a device, or a computer program product. Therefore, the embodiments of the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0133] Embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate means for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or multiple blocks.
[0134] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implements the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or multiple blocks.
[0135] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device, so that a series of operation steps are executed on the computer or other programmable terminal device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or multiple blocks.
[0136] Although the preferred embodiments of the embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications to these embodiments once they know the basic creative concepts. Therefore, the appended claims are intended to be construed as including the preferred embodiments and all changes and modifications falling within the scope of the embodiments of the present invention.
[0137] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or terminal device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the existence of additional identical elements in the process, method, article or terminal device comprising the said element.
[0138] The above has introduced in detail a mirror image generation method, apparatus and storage medium provided by the present invention. Specific examples are used in this text to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.
Claims
1. A method for generating an image, characterized in that, Including: Obtain a blank image; Obtain multiple module files, each of the module files respectively including installation information of components or dependency libraries; Obtain a recipe file, the recipe file including the path of a target module file; According to the path of the target module file, call the target module file, and according to the installation information in the target module file, install the components or dependency libraries in the blank image to generate a target image.
2. The method for generating an image according to claim 1, characterized in that, One of the module files includes installation information of one component or installation information of one dependency library; the number of the recipe files is one; the target module file is at least one of the multiple module files.
3. The method for generating an image according to claim 1, characterized in that, The method further includes: Detect a first modification operation of the user on the module file; Modify the module file according to the first modification operation.
4. The method for generating an image according to claim 1, characterized in that, The installation information includes the acquisition path of the installation package of the component or dependency library, the acquisition path of the installation script, and the installation path pointing to the blank image. Then, installing the component or dependency library in the blank image according to the installation information in the target module file includes: According to the acquisition path of the installation package of the component or dependency library in the target module file, obtain the installation package of the component or dependency library; According to the acquisition path of the installation script in the target module file, obtain the installation script; Execute the installation script, run the installation package, and install the component or dependency library in the blank image pointed to by the installation path.
5. The method for generating an image according to claim 1, characterized in that, The method further includes: Containerize the target image to obtain a target container; Obtain verification information of the components or dependency libraries in the target container; When running the components or dependency libraries in the target container, verify the user permissions according to the verification information; After the verification passes, run the components or dependency libraries in the target container according to the user permissions.
6. The method for generating an image according to claim 5, characterized in that, The method further includes: When detecting a second modification operation of the user on the verification information, modify the verification information according to the second modification operation.
7. The method for generating an image according to claim 5, characterized in that, The verification information includes at least one of user information and password information. Then, verifying the user permissions according to the verification information includes: Verify the user permissions according to the user information and / or password information corresponding to the components or dependency libraries in the target container.
8. The method for generating an image according to claim 1, characterized in that, The number of the target module files is multiple, and the recipe file further includes the call order of the multiple target module files. Then, according to the path of the target module file, calling the target module file, and according to the installation information in the target module file, installing the components or dependency libraries in the blank image to generate a target image includes: According to the call order of the multiple target module files, sequentially according to the paths of the multiple target module files, call the multiple target module files, and according to the installation information in each target module file, install the components or dependency libraries in the blank image to generate a target image.
9. The method for generating an image according to claim 1, characterized in that, The recipe file further includes the output format and output path of the target image, where the output format is used to specify the generation format of the target image. Then, generating the target image includes: Generating a target image in the specified format according to the output format, and saving the target image under the output path.
10. The method for generating an image according to claim 1, characterized in that, The recipe file includes a blank image creation instruction. Then, obtaining the blank image includes: Executing the blank image creation instruction to obtain a blank image.
11. The method for generating an image according to claim 1, characterized in that,The recipe file further includes the operating system type, which is used to specify the running environment after containerizing the target image. The method further includes: Deploying an operating system according to the operating system type; Containerizing the target image to run in the operating system.
12. A mirror image generation device, characterized in that, Including: A processor and a memory, where a computer program is stored in the memory. When the processor executes the computer program, it performs the steps of the image generation method according to any one of claims 1-11.
13. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, it implements the steps of the image generation method according to any one of claims 1-11.