CN117555563B - Method and device for constructing platform mirror image, computer equipment and storage medium - Google Patents

Method and device for constructing platform mirror image, computer equipment and storage medium Download PDF

Info

Publication number
CN117555563B
CN117555563B CN202311603203.5A CN202311603203A CN117555563B CN 117555563 B CN117555563 B CN 117555563B CN 202311603203 A CN202311603203 A CN 202311603203A CN 117555563 B CN117555563 B CN 117555563B
Authority
CN
China
Prior art keywords
target
platform
mirror image
directory
mirror
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311603203.5A
Other languages
Chinese (zh)
Other versions
CN117555563A (en
Inventor
吴少斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Dingjia Computer Technology Co ltd
Original Assignee
Guangzhou Dingjia Computer Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Dingjia Computer Technology Co ltd filed Critical Guangzhou Dingjia Computer Technology Co ltd
Priority to CN202311603203.5A priority Critical patent/CN117555563B/en
Publication of CN117555563A publication Critical patent/CN117555563A/en
Application granted granted Critical
Publication of CN117555563B publication Critical patent/CN117555563B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/63Image based installation; Cloning; Build to order
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a method and a device for constructing a platform mirror image, computer equipment and a storage medium. The method comprises the following steps: the dock server respectively acquires a target platform corresponding to the platform image to be built, a software installation package corresponding to the target platform, an image builder and a software installation package of the target platform. Decompressing the software installation package to a first target directory corresponding to each target platform, processing the first target directory to obtain a second target directory aiming at soft link information in the mirror image root directory of the basic mirror image of each target platform, writing the content of the second target directory into the mirror image root directory of each basic mirror image, and finally obtaining the platform mirror image corresponding to each target platform. The method can realize that one platform mirror image corresponds to one platform, does not need to be compatible with a plurality of platforms, reduces the requirements on the types and the quantity of the server platforms, and saves the resource cost.

Description

Method and device for constructing platform mirror image, computer equipment and storage medium
Technical Field
The present application relates to the field of container technologies, and in particular, to a method, an apparatus, a computer device, a storage medium, and a computer program product for constructing a platform image.
Background
With the development of big data and cloud computing technology, container technology has emerged, which is a way to implement operating system virtualization, and by using containers, the code, configuration and dependency of an application program can be easily packaged, and become a building block that is easy to use. Container mirroring is an important component in container technology, allowing applications to be easily deployed and run in different environments.
Currently popular is buildx (mirror build component) provided using a docker (open-source containerized platform). The call binfmt _misc (register and use custom binary format interpreter) support tool starts qemu (Quick Emulator, virtualized software, simulating multiple hardware platforms and running different operating systems in it) of the corresponding platform to compile, conventional dock mirror image making requires the server of the corresponding platform to compile, if the number of platforms to which the mirror image is compatible is large, the requirements on the type and number of the platforms of the server are high, and unnecessary resource waste is caused.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a construction method, apparatus, computer device, computer readable storage medium, and computer program product that enable platform mirroring that is not necessarily compatible with multiple platforms.
In a first aspect, the present application provides a method for constructing a platform image, which is applied to a dock server, and includes:
Acquiring target platforms corresponding to the images of the platforms to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
aiming at each target platform, acquiring a corresponding mirror image constructor, and decompressing each software installation package to a first target catalog in the mirror image constructor corresponding to each target platform;
Processing each first target directory based on soft link information of the mirror image root directory of the basic mirror image of each target platform to obtain a second target directory corresponding to each target platform;
And writing the content of the second target directory into a mirror root directory of the basic mirror of the corresponding target platform to obtain the platform mirror corresponding to each target platform.
In one embodiment, each mirror image builder carries multiple types of decompression tools therein; decompressing each software installation package to a first target catalog in a mirror image constructor corresponding to each target platform, wherein the method comprises the following steps:
aiming at each mirror image constructor, acquiring the installation package type of each software installation package, and acquiring a target type decompression tool matched with the installation package type from a plurality of types of decompression tools carried in the mirror image constructor;
And decompressing each software installation package to a first target catalog in each mirror image constructor through a decompression tool of the target type.
In one embodiment, the multiple types of decompression tools carried in the mirror builder include: a Debian software package decompression tool and an RPM software package decompression tool;
Obtaining a target type decompression tool matched with the type of the installation package from a plurality of types of decompression tools carried in the mirror image constructor, wherein the method comprises the following steps:
Under the condition that the installation package type is a Debian software package type, taking a Debian software package decompression tool as a decompression tool of a target type;
In the case that the installation package type is the RPM software package type, taking the RPM software package decompression tool as a decompression tool of a target type.
In an exemplary embodiment, before obtaining the corresponding mirror image builder for each target platform, the method further includes:
Acquiring the number of platform types of the target platform;
the same number of mirror image constructors as the number of platform types are created in parallel.
In one embodiment, processing each first target directory based on soft link information of a mirror root directory of a base mirror of each target platform to obtain a second target directory corresponding to each target platform includes:
Acquiring first directory naming information contained in a first target directory and soft link information contained in a mirror image root directory of a basic mirror image of each target platform;
under the condition that the first directory naming information is consistent with the target soft link information, acquiring second directory naming information corresponding to the soft link information, and updating the first directory naming information contained in the first target directory into the second directory naming information; the target soft link information is any one of soft link information contained in the mirror root directory of the basic mirror of each target platform.
In one embodiment, after obtaining the platform images corresponding to the target platforms respectively, the method further includes:
uploading the mirror images of the platforms to a mirror image warehouse;
The method further comprises the steps of:
obtaining a mirror image list corresponding to each platform mirror image;
and generating a mirror image list according to each mirror image list, and uploading the mirror image list to a mirror image warehouse.
In a second aspect, the present application further provides a device for constructing a platform image, which is applied to a docker server, and includes:
the acquisition module is used for acquiring target platforms corresponding to the images of the platforms to be constructed respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
the decompression module is used for acquiring corresponding mirror image constructors aiming at each target platform and decompressing each software installation package to a first target catalog in the mirror image constructors corresponding to each target platform;
The second target catalog generation module is used for processing each first target catalog based on the soft link information of the mirror image root catalog of the basic mirror image of each target platform to obtain a second target catalog corresponding to each target platform;
The platform image construction module is used for writing the content of the second target directory into the image root directory of the basic image of the corresponding target platform to obtain the platform images corresponding to the target platforms respectively.
In a third aspect, the present application also provides a computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
Acquiring target platforms corresponding to the images of the platforms to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
aiming at each target platform, acquiring a corresponding mirror image constructor, and decompressing each software installation package to a first target catalog in the mirror image constructor corresponding to each target platform;
Processing each first target directory based on soft link information of the mirror image root directory of the basic mirror image of each target platform to obtain a second target directory corresponding to each target platform;
And writing the content of the second target directory into a mirror root directory of the basic mirror of the corresponding target platform to obtain the platform mirror corresponding to each target platform.
In a fourth aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
Acquiring target platforms corresponding to the images of the platforms to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
aiming at each target platform, acquiring a corresponding mirror image constructor, and decompressing each software installation package to a first target catalog in the mirror image constructor corresponding to each target platform;
Processing each first target directory based on soft link information of the mirror image root directory of the basic mirror image of each target platform to obtain a second target directory corresponding to each target platform;
And writing the content of the second target directory into a mirror root directory of the basic mirror of the corresponding target platform to obtain the platform mirror corresponding to each target platform.
In a fifth aspect, the application also provides a computer program product comprising a computer program which, when executed by a processor, performs the steps of:
Acquiring target platforms corresponding to the images of the platforms to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
aiming at each target platform, acquiring a corresponding mirror image constructor, and decompressing each software installation package to a first target catalog in the mirror image constructor corresponding to each target platform;
Processing each first target directory based on soft link information of the mirror image root directory of the basic mirror image of each target platform to obtain a second target directory corresponding to each target platform;
And writing the content of the second target directory into a mirror root directory of the basic mirror of the corresponding target platform to obtain the platform mirror corresponding to each target platform.
The method, the device, the computer equipment, the storage medium and the computer program product for constructing the platform mirror image respectively acquire a target platform corresponding to the platform mirror image to be constructed, a software installation package corresponding to the target platform, a mirror image constructor and a software installation package of the target platform. Decompressing the software installation package to a first target directory corresponding to each target platform, processing the first target directory to obtain a second target directory aiming at soft link information of the mirror image root directory of the basic mirror image of each target platform pair, writing the content of the second target directory into the mirror image root directory of each basic mirror image, and finally obtaining the platform mirror image corresponding to each target platform. By using a plurality of mirror image constructors as carriers for loading the mirror images of the platforms, the construction of the mirror images of the platforms is carried out on the mirror image constructors, so that one-to-one correspondence is realized, and therefore, the mirror images of the platforms are matched with one platform only without being compatible with a plurality of platforms, the requirements on the types and the quantity of the platforms of the server are reduced, and the resource cost is saved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the related art, the drawings that are required to be used in the embodiments or the related technical descriptions will be briefly described, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to the drawings without inventive effort for those skilled in the art.
FIG. 1 is an application environment diagram of a method of building a platform image in one embodiment;
FIG. 2 is a flow diagram of a method of building a platform image in one embodiment;
FIG. 3 is a flow diagram of second target directory generation in one embodiment;
FIG. 4 is a flow chart of a method of constructing a platform image according to another embodiment;
FIG. 5 is a block diagram of an apparatus for building a platform image in one embodiment;
fig. 6 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The method for constructing the platform mirror image provided by the embodiment of the application can be applied to an application environment shown in figure 1. Wherein the docker server 102 installs and runs a physical or virtual server of the docker engine. The docker engine is an open-source containerized platform that can package applications and their dependent items into containers for deployment and operation in different environments. The dock server 102 obtains target platforms corresponding to the image of the build platform from the terminal 101, obtains software installation packages and basic images corresponding to the target platforms (which are also disclosed as image builders in other places of the application), downloads respective corresponding image constructors for the target platforms, decompresses the software installation packages into first target catalogues constructed by the respective corresponding images, and obtains second target catalogues based on soft link information of image root catalogues of the basic images of the target platforms; and writing the content of the second target directory into the mirror root directory of the basic mirror, and finally obtaining a platform mirror corresponding to each target platform, so that the terminal 101 can call the platform mirror in the dock server 102 to perform service processing. The terminal 101 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices and portable wearable devices, and the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The docker server 102 may be implemented as a stand-alone server or as a cluster of servers.
In an exemplary embodiment, as shown in fig. 2, a method for constructing a platform image is provided, and an example of application of the method to the docker server 102 in fig. 1 is described, which includes the following steps S201 to S204. Wherein:
step S201, obtaining target platforms corresponding to the to-be-built platform images respectively, and obtaining software installation packages corresponding to the target platforms and basic images of the target platforms.
Wherein, the platform image (disclosed as a builder image elsewhere in the present application) can be understood as a snapshot of a preconfigured operating system and software environment, which can be used to rapidly deploy and replicate the same platform environment; including all necessary components that make up the platform, such as the operating system, application programs, library files, configuration files, etc. The snapshot needs to be placed on a movable cloud platform, which is referred to as the target platform. A software installation package is understood to be the building material necessary to build the cloud platform, and a base image is the basis for building other images, and is a minimized operating system image, and typically only contains the core components of the operating system and some basic tools for building and expanding the platform image.
Optionally, the dock server acquires a target platform corresponding to the platform image to be built in advance, acquires a software installation package necessary for building the target platform, and downloads the basic image of each target platform to make preparation work in advance for subsequent building of the platform image.
Step S202, for each target platform, a corresponding mirror image constructor is obtained, and each software installation package is decompressed to a first target catalog in the mirror image constructor corresponding to each target platform.
The target platform can be understood as platform information in the platform image to be constructed, namely a corresponding target platform, and a corresponding image constructor needs to be selected aiming at the platform information; the mirror builder, i.e., builder container, is understood to be a container that loads the target platform installation package, while the build of the platform mirror is performed here as well, since the platform is installed directly on the container and therefore does not have to be compatible with the buildx plug-ins of the server. The first target directory, i.e., the/target directory, is not a fixed directory within the docker server, but rather is a specific output directory that is generated during the mirror construction process to save output content.
For example, respectively constructing corresponding mirror image constructors for the target platforms, providing a place where mirror image construction occurs, decompressing software installation packages for constructing each target platform, and storing the decompressed software installation packages in a first target directory to lay a foundation for continuing to construct the mirror images of the platforms.
Step S203, based on the soft link information of the mirror image root directory of the basic mirror image of each target platform, processing each first target directory to obtain a second target directory corresponding to each target platform.
The system root directory is the starting point of the whole file system, and is also the father directory of other directories, and related files can be accessed through soft link information in the system root directory. The second target directory may be understood as a final output directory obtained after processing the first target directory.
And step S204, writing the content of the second target directory into the mirror image root directory of the basic mirror image of the corresponding target platform to obtain the platform mirror images respectively corresponding to the target platforms.
The mirror root directory is a virtual directory in the mirror image of the platform and does not correspond to an actual file system of the host, and when the platform runs, the mirror root directory is mapped into the file system of the host, so that the container can access files and directories of the host. The mirror root directory is also the starting point for all file systems in the platform mirror.
Illustratively, the image layer of the image builder is exported, the image layer contains all of the contents of the second target directory, and this image layer is merged into the base image, resulting in the platform image. It can also be understood that the construction of the platform image is realized by copying all the contents under the second target directory to the root directory of the base image.
In the method for constructing the platform image, a target platform corresponding to the platform image to be constructed, a software installation package corresponding to the target platform, an image constructor and a software installation package of the target platform are respectively obtained. Decompressing the software installation package to a first target directory corresponding to each target platform, processing the first target directory to obtain a second target directory aiming at soft link information of the mirror image root directory of the basic mirror image of the target platform, copying the content of the second target directory to the mirror image root directory of each basic mirror image, and finally obtaining the platform mirror image corresponding to each target platform. By using a plurality of mirror image constructors with completely consistent architecture as carriers for loading the mirror images of the platforms, the construction of the mirror images of the platforms is carried out on the mirror image constructors, so that one-to-one correspondence is realized, and therefore, the mirror images of the platforms are only matched with one platform without being compatible with a plurality of platforms, the requirements on the types and the quantity of the platforms of the server are reduced, and the resource cost is saved.
In one embodiment, each mirror image builder carries multiple types of decompression tools therein; decompressing each software installation package to a first target catalog in a mirror image constructor corresponding to each target platform, wherein the method comprises the following steps: aiming at each mirror image constructor, acquiring the installation package type of each software installation package, and acquiring a target type decompression tool matched with the installation package type from a plurality of types of decompression tools carried in the mirror image constructor; and decompressing each software installation package to a first target catalog in each mirror image constructor through a decompression tool of the target type.
The source of the software installation package can be an official software source or company software which can be compiled by the user, but the software installation package is downloaded and provided if a dependent package exists at the same time, and the range of the dependent package is determined based on the software package installed by the basic mirror image of each target platform.
Optionally, determining the type of the software installation package, wherein different types of software installation packages need to be decompressed by adopting different decompression tools, selecting a corresponding decompression tool according to the type of the software installation package, and decompressing the software installation package into the first target catalogue of each mirror image constructor.
In this embodiment, the docker server firstly screens the type of the software installation package, and selects a decompression tool matched with the software installation package according to the type of the software installation package to decompress, so that the decompression speed can be increased, and the speed of constructing the platform mirror image is further increased.
In one embodiment, among other things, the multiple types of decompression tools carried in the mirror builder include: a Debian software package decompression tool and an RPM software package decompression tool; obtaining a target type decompression tool matched with the type of the installation package from a plurality of types of decompression tools carried in the mirror image constructor, wherein the method comprises the following steps:
Under the condition that the installation package type is a Debian software package type, taking a Debian software package decompression tool as a decompression tool of a target type;
In the case that the installation package type is the RPM software package type, taking the RPM software package decompression tool as a decompression tool of a target type.
The Debian software package decompression tool, namely dpkg-deb, and the RPM software package decompression tool, namely RPM2cpio, are command line tools for decompressing and extracting files in an installation package, wherein the Debian software package decompression tool aims at a Debian software package, namely a deb file, and the RPM software package decompression tool aims at an RPM software package, namely a RPM file.
In this embodiment, the decompression tool adapted is selected to decompress by judging the type of the software package, so as to accelerate the construction speed of the target platform, and further accelerate the construction speed of the platform mirror image.
In one embodiment, before obtaining the corresponding mirror image builder for each target platform, the method further includes: acquiring the number of platform types of the target platform; the same number of mirror image constructors as the number of platform types are created in parallel.
The type of the target platform refers to the type of target hardware or operating system platform on which the built software or application program is to run, and it is very important to select a platform type suitable for the target platform, because the difference between hardware and operating system of different platforms may cause the behavior and performance of the software installation package on different platforms to be different.
In this embodiment, by determining the platform types of each target platform, the mirror image constructors with the same number are created in parallel according to the number of the platform types, so as to ensure the normal operation of the software installation packages corresponding to each target platform in the mirror image constructors after decompression, and simultaneously, the parallel creation of the corresponding mirror image constructors also achieves the technical effect of parallel creation of multiple platform mirror images.
In an exemplary embodiment, as shown in fig. 3, processing each first target directory based on soft link information of a mirror root directory of a base mirror of each target platform to obtain a second target directory corresponding to each target platform includes steps S301 to S302. Wherein:
Step S301, obtaining first directory naming information included in the first target directory and soft link information included in the mirror root directory of the base mirror of each target platform.
The first directory naming information is used for representing file directory information generated after the software installation packages corresponding to the target platforms are decompressed under the first target directory. The mirror image root directory of the basic mirror image of the target platform also contains directory information of various files, the directory file information contains soft link information, and clicking can jump to the file linked by the soft link.
Step S302, under the condition that the first directory naming information is consistent with the target soft link information, second directory naming information corresponding to the soft link information is obtained, and the first directory naming information contained in the first target directory is updated to be the second directory naming information; the target soft link information is any one of soft link information contained in the mirror root directory of the basic mirror of each target platform.
The first directory naming information may be any directory naming information in the first target directory, and the target soft link information may be any soft link information in the mirror root directory of the base mirror of each target platform. Directory naming information the second target directory may be understood as the target directory after modification of the first directory naming information in the first target directory to obtain the second directory naming information.
Optionally, when any directory naming information in the first target directory and any soft link information in the mirror root directory of the base mirror image of each target platform are the same, the directory naming information needs to be modified to be distinguished from the same soft link information in the mirror root directory of the base mirror image of each target platform, so that the system inherent file is prevented from being lost, and the mirror constructor cannot be started.
In this embodiment, by comparing the first directory naming information in the first target directory with the target soft link information in the mirror root directory of the base mirror image of each target platform, if the first directory naming information is consistent with the target soft link information, the first directory naming information is modified to obtain the second directory naming information, so as to achieve the technical effect of avoiding the system file loss and the mirror image builder startup failure
In one embodiment, after obtaining the platform images corresponding to the target platforms respectively, the method further includes: uploading the mirror images of the platforms to a mirror image warehouse;
The method further comprises the steps of:
Obtaining a mirror image list corresponding to each platform mirror image; and generating a mirror image list according to each mirror image list, and uploading the mirror image list to a mirror image warehouse.
The mirror image warehouse is stored in the docker server and is used for storing all the platform mirror images constructed by the embodiment, the mirror image list can be understood as a unique identity identification code of each platform mirror image, mirror image lists among different platform mirror images are different, the mirror image list can be used for searching the required platform mirror images through the mirror image list, the mirror image list can be multiple but different in name, and only one mirror image list comprises all the mirror image lists.
In this embodiment, after finishing the construction of the platform images, the dock server uploads the successfully constructed platform images to the image warehouse convenient for taking, further integrates the platform images, attaches an identification code (i.e., an image list) to each platform image, and integrates all the image lists to form an image list, and the image list is uploaded to the image warehouse at the same time, so that the required platform images can be quickly found out according to the list, thereby accelerating the speed of calling the platform images.
In an exemplary embodiment, as shown in fig. 4, a detailed step of a method for constructing a platform image includes:
And downloading and constructing a mirror image builder by a docker server. The platform architecture of the builder mirror depends on a docker server, and has no specific hard requirements, such as docke servers of a general-purpose amd64 platform; the builder image needs to be provided with dpkg-deb (Debian package (. Deb file)), RPM2cpio (RPM package (. RPM file)) and other related tools.
2. And downloading a software installation package of the target platform. The source of the software installation package can be an official software source or self-compiled company software. But requires an architecture that supports the target platform. Such as openssh service installation packages that support a, B, and C. If a dependency package exists, the dependency package is also provided, and the scope of the dependency package is determined according to the software package installed in the base image of the target platform.
3. The installation package is decompressed to the first/target directory. The different tools are used to decompress the installation packages according to the different types. Currently the dominant types are the Debian package and RPM package, with dpkg-deb and RPM2cpio tools for decompression operations, respectively.
4. And comparing the directory name in the first/target directory with the soft link names in the mirror root directory of the basic mirror of each target platform, and modifying the directory name in the first/target directory if the names are consistent to obtain a second/target directory. Because of the soft link in the root directory of the base image, the copy function of the file of the docker can create a directory with the same name as the soft link in the target image, and cover the original soft link of the target image, so that some system files are lost, and the container is started to crash.
5. And downloading the base image of the target platform, and copying the second/target directory content of the builder container into a base image root directory (/) by using a copy function of the file of the dock. The principle of the method is that the mirror image layer of the builder container (the layer contains all contents under the second/target directory) is exported and then merged into the basic mirror image, so that the integration of the mirror images is realized.
6. And uploading each constructed platform image to an image warehouse.
7. And making MANIFEST LIST, and uploading to a mirror warehouse. The image list (manifest) is a file in which basic information of an image, such as architecture, size, and the like, is contained. And MANIFEST LIST is a list of mirror images for storing mirror image information for a plurality of different os/arches. We can create a MANIFEST LIST mirror image (e.g., a ubuntu-amd 64 and a ubuntu20-arm64 mirror image) to point to one or more different platform architectures and then provide a unique mirror name to the user (e.g., ubuntu).
Compared with the prior art, the application has the following advantages:
1. According to the number of the platform types of the target platform, the mirror image constructors with the same number are started in parallel, so that the problem that the software installation package cannot normally run after being decompressed due to the fact that the platform types are not consistent can be avoided, and meanwhile, the technical effect of constructing multiple platform mirror images in parallel is achieved.
2. Under the condition that the first directory naming information of the first target directory is consistent with the target soft link information, modifying the first directory naming information into second directory naming information different from the target soft link information, performing the above traversal and modification on all contents in the first target directory, and preventing soft link information from being covered to cause the mirror image constructor to start up and crash when a basic mirror image is constructed subsequently.
3. The process of constructing the mirror image of each platform is carried out in the corresponding mirror image constructor, so that the plug-in buildx in the compatible docker server is not needed, meanwhile, the corresponding relationship between the mirror image of the platform and the mirror image constructor is formed, a plurality of platforms are not needed to be compatible, and the resource cost is reduced.
4. And finally, forming a mirror image list composed of mirror image lists, and quickly searching through the list, and realizing cross-platform construction platform mirror images and cross-platform calling platform mirror images.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a platform mirror image construction device for realizing the above-mentioned platform mirror image construction method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiment of the device for constructing one or more platform images provided below may be referred to the limitation of the method for constructing a platform image hereinabove, and will not be described herein.
In an exemplary embodiment, as shown in fig. 5, there is provided a platform image constructing apparatus, including: an acquisition module 501, a decompression module 502, a second target directory generation module 503, and a platform image construction module 504, wherein:
The obtaining module 501 is configured to obtain target platforms corresponding to the images of the platforms to be built, and obtain software installation packages corresponding to the target platforms, and base images of the target platforms.
The decompression module 502 is configured to obtain, for each target platform, a corresponding image builder, and decompress each software installation package to a first target directory in the image builder corresponding to each target platform.
And the second target directory generating module 503 is configured to process each first target directory based on the soft link information of the mirror root directory of the base mirror of each target platform, to obtain a second target directory corresponding to each target platform.
The platform image construction module 504 is configured to write the content of the second target directory into an image root directory of the base image of the corresponding target platform, so as to obtain the platform images corresponding to the target platforms respectively.
In one embodiment, each mirror image builder carries multiple types of decompression tools, and the decompression module 502 is specifically configured to obtain, for each mirror image builder, an installation package type of each software installation package, and obtain, from the multiple types of decompression tools carried in the mirror image builder, a decompression tool of a target type that is matched with the installation package type; and decompressing each software installation package to a first target catalog in each mirror image constructor through a decompression tool of the target type.
In one exemplary embodiment, the multiple types of decompression tools carried in the mirror builder include: the decompression module 502 is specifically further configured to use the debrian software package decompression tool as a target type decompression tool when the installation package type is a debrian software package type; in the case that the installation package type is the RPM software package type, taking the RPM software package decompression tool as a decompression tool of a target type.
In one embodiment, the number of platform types of the target platform is specifically obtained before entering the decompression module 502; the same number of mirror image constructors as the number of platform types are created in parallel.
In one embodiment, the second target directory generating module 503 is specifically configured to obtain first directory naming information included in the first target directory, and soft link information included in a mirror root directory of the base mirror of each target platform; under the condition that the first directory naming information is consistent with the target soft link information, acquiring second directory naming information corresponding to the soft link information, and updating the first directory naming information contained in the first target directory into the second directory naming information; the target soft link information is any one of soft link information contained in the mirror root directory of the basic mirror of each target platform.
In one embodiment, the device is further specifically configured to upload each platform image to an image repository; obtaining a mirror image list corresponding to each platform mirror image; and generating a mirror image list according to each mirror image list, and uploading the mirror image list to a mirror image warehouse.
The modules in the above-described platform image constructing apparatus may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one exemplary embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 6. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing corresponding target platform data, target platform software installation package data, target platform basic mirror image data, mirror image builder target directory data and system root directory data. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a method of constructing a platform image.
It will be appreciated by those skilled in the art that the structure shown in FIG. 6 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In an exemplary embodiment, a computer device is provided, including a memory and a processor, where the memory stores a computer program, and the processor implements the method for building a platform image of the above embodiment when the computer program is executed.
In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the method of constructing a platform image of the above embodiments.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the method of constructing a platform image of the above-described embodiments.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are both information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data are required to meet the related regulations.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magneto-resistive random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (PHASE CHANGE Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.

Claims (10)

1. A method for constructing a platform image, applied to a docker server, the method comprising:
Acquiring target platforms corresponding to the platform images to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
for each target platform, acquiring a corresponding mirror image constructor, and decompressing each software installation package to a first target directory in the mirror image constructor corresponding to each target platform;
Acquiring first directory naming information contained in the first target directory and soft link information contained in a mirror image root directory of a basic mirror image of each target platform;
under the condition that the first directory naming information is consistent with the target soft link information, second directory naming information corresponding to the soft link information is obtained, the first directory naming information contained in the first target directory is updated to the second directory naming information, and a second target directory corresponding to each target platform is obtained; the target soft link information is any one of soft link information contained in a mirror root directory of a basic mirror of each target platform;
And writing the content of the second target directory into a mirror image root directory of the basic mirror image of the corresponding target platform to obtain platform mirror images respectively corresponding to the target platforms.
2. The method of claim 1, wherein each of said mirror image builders carries therein a plurality of types of decompression tools; decompressing each software installation package to a first target directory in a mirror image constructor corresponding to each target platform, wherein the decompressing comprises the following steps:
For each mirror image constructor, acquiring the type of an installation package of each software installation package, and acquiring a target type decompression tool matched with the type of the installation package from a plurality of types of decompression tools carried in the mirror image constructor;
And decompressing each software installation package to a first target catalog in each mirror image constructor through a decompression tool of the target type.
3. The method of claim 2, wherein the plurality of types of decompression tools carried in the mirror builder comprise: a Debian software package decompression tool and an RPM software package decompression tool;
The obtaining a target type decompression tool matched with the installation package type from a plurality of types of decompression tools carried in the mirror image constructor comprises the following steps:
Taking the Debian software package decompression tool as the decompression tool of the target type under the condition that the installation package type is the Debian software package type;
And taking the RPM software package decompression tool as the decompression tool of the target type under the condition that the installation package type is the RPM software package type.
4. The method of claim 2, wherein before obtaining the corresponding mirror builder for each of the target platforms, further comprising:
Acquiring the number of platform types of the target platform;
The same number of mirror image constructors as the number of platform types are created in parallel.
5. The method of claim 1, wherein after obtaining the platform images corresponding to the target platforms, further comprises:
Uploading each platform mirror image to a mirror image warehouse;
The method further comprises the steps of:
obtaining a mirror image list corresponding to each platform mirror image;
And generating a mirror image list according to each mirror image list, and uploading the mirror image list to the mirror image warehouse.
6. A device for constructing a platform image, applied to a docker server, comprising:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring target platforms corresponding to the platform images to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
the decompression module is used for acquiring corresponding mirror image constructors for each target platform and decompressing each software installation package to a first target catalog in the mirror image constructors corresponding to each target platform;
The second target directory generation module is used for acquiring first directory naming information contained in the first target directory and soft link information contained in the mirror root directory of the basic mirror of each target platform; under the condition that the first directory naming information is consistent with the target soft link information, second directory naming information corresponding to the soft link information is obtained, the first directory naming information contained in the first target directory is updated to the second directory naming information, and a second target directory corresponding to each target platform is obtained; the target soft link information is any one of soft link information contained in a mirror root directory of a basic mirror of each target platform;
And the platform image construction module is used for writing the content of the second target directory into an image root directory of the basic image of the corresponding target platform to obtain the platform images respectively corresponding to the target platforms.
7. The apparatus of claim 6, wherein each of said mirror image constructors carries a plurality of types of decompression tools therein; the decompression module is further configured to:
For each mirror image constructor, acquiring the type of an installation package of each software installation package, and acquiring a target type decompression tool matched with the type of the installation package from a plurality of types of decompression tools carried in the mirror image constructor;
And decompressing each software installation package to a first target catalog in each mirror image constructor through a decompression tool of the target type.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 5 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 5.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method according to any one of claims 1 to 5.
CN202311603203.5A 2023-11-28 2023-11-28 Method and device for constructing platform mirror image, computer equipment and storage medium Active CN117555563B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311603203.5A CN117555563B (en) 2023-11-28 2023-11-28 Method and device for constructing platform mirror image, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311603203.5A CN117555563B (en) 2023-11-28 2023-11-28 Method and device for constructing platform mirror image, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117555563A CN117555563A (en) 2024-02-13
CN117555563B true CN117555563B (en) 2024-10-18

Family

ID=89823041

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311603203.5A Active CN117555563B (en) 2023-11-28 2023-11-28 Method and device for constructing platform mirror image, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117555563B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117950646B (en) * 2024-03-26 2024-06-07 苏州元脑智能科技有限公司 Software development method, device, computer equipment, storage medium and program product

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111522560A (en) * 2020-04-21 2020-08-11 北京三快在线科技有限公司 Software installation method and device, storage medium and electronic equipment
CN112506615A (en) * 2020-12-11 2021-03-16 浪潮电子信息产业股份有限公司 JavaWeb application deployment method, device, equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109391688A (en) * 2018-09-29 2019-02-26 郑州云海信息技术有限公司 The acquisition methods and device of image file in cloud computing system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111522560A (en) * 2020-04-21 2020-08-11 北京三快在线科技有限公司 Software installation method and device, storage medium and electronic equipment
CN112506615A (en) * 2020-12-11 2021-03-16 浪潮电子信息产业股份有限公司 JavaWeb application deployment method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN117555563A (en) 2024-02-13

Similar Documents

Publication Publication Date Title
CN111492347B (en) System and method for updating a container
CN112256286B (en) Application running method and device and computer storage medium
CN111930473B (en) Method and apparatus for deploying image recognition service on container cloud
US10606646B1 (en) Systems and methods for creating a data volume from within a software container and initializing the data volume with data
US20140372998A1 (en) App package deployment
CN111897623B (en) Cluster management method, device, equipment and storage medium
CN111223036B (en) GPU (graphics processing unit) virtualization sharing method and device, electronic equipment and storage medium
CN117555563B (en) Method and device for constructing platform mirror image, computer equipment and storage medium
CN113885935A (en) Resource packaging method and device, electronic equipment and computer readable storage medium
CN104731622A (en) Application program loading method and device and mobile terminal
KR101036675B1 (en) A method to use global variables for pre-efi initialization modules in efi-based firmware
CN113296891A (en) Multi-scene knowledge graph processing method and device based on platform
CN115774701B (en) Data sharing method and device, electronic equipment and storage medium
US20230401080A1 (en) Reducing deployment time for container clones in computing environments
CN113741952A (en) Software package management method, device, equipment and medium
CN115016785B (en) Front-end item packaging method and device for multi-environment sharing
CN112506526B (en) Data presentation software deployment method and device and electronic equipment
CN115525300A (en) Incremental mirror image packaging method and system in container cloud scene
US9195457B1 (en) Interactive application programming interface documentation
CN114237638A (en) Operating system installation method and device, computer equipment and storage medium
US20220138146A1 (en) Merging composite images into a new filesystem namespace
CN110888649B (en) Application deployment method, application baseline creation method and device
CN115167970A (en) Hybrid method of performing lazy pull of container mirror
TW202040382A (en) Mobile device and data sharing method
US11720374B1 (en) Dynamically overriding a function based on a capability set

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant