Method and apparatus for managing container images
By using qcow2 files and mirror proxy virtual machines in Kata Containers, the shortcomings of the lightweight virtual machine container engine when compatible with container mirroring standards are solved, and efficient management of container mirroring and utilization of traditional virtual machine features are achieved.
Patent Information
- Application Number
- CN201910602797.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-07-05
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2039-07-05
Smart Images

Figure CN110308972B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer technology, and more particularly, to methods and apparatuses for managing container images. Background Art
[0002] With the rise of technologies such as Docker and Kubernetes, containers are increasingly widely used in cloud environments. The industry has also put forward new requirements for the isolation of containers, hoping to endow containers with isolation comparable to traditional virtual machines in order to be applicable to multi-tenant cloud environments such as public clouds. Kata Containers is a new container engine that meets such standards. It is essentially a lightweight virtual machine that uses hardware virtualization technology to isolate multi-tenants, while supporting existing container standards (OCI) and being compatible with Docker and Kubernetes.
[0003] However, container engines such as Kata Containers based on lightweight virtual machines have certain deficiencies when compatible with existing container image standards. Because container image storage is usually implemented based on a layered file system, that is, container images are presented in the form of directories on the host, and when virtual machines need to use them, they need to be passed through to the virtual machine by sharing directories. However, the current shared directory technologies (9pfs, virtiofs) are not very perfect, and many important features, such as quota (disk quota), speed limit, snapshot, online expansion, etc. are missing. Therefore, it is necessary to implement a new container image management method that can fully fit container engines based on lightweight virtual machines such as Kata Containers. Summary of the Invention
[0004] Embodiments of the present disclosure provide methods and apparatuses for managing container images.
[0005] In a first aspect, embodiments of the present disclosure provide a method for managing container images, including: creating a qcow2 file and starting an image proxy virtual machine with a virtual disk of the qcow2 file; mounting the virtual disk of the qcow2 file to a specified first image directory in the image proxy virtual machine; pulling an image from a container image source to the specified first image directory in the image proxy virtual machine; taking a snapshot of the qcow2 file to generate a qcow2 snapshot file; starting a lightweight virtual machine and virtualizing the qcow2 snapshot file into a disk of the lightweight virtual machine and mounting it to the lightweight virtual machine; and mounting the disk virtualized from the qcow2 snapshot file to a specified second image directory in the lightweight virtual machine.
[0006] In some embodiments, the method further includes: pushing the image used by the lightweight virtual machine to a specified second image directory in the lightweight virtual machine; taking a snapshot of the qcow2 file in the second image directory to generate a target qcow2 file; virtualizing the target qcow2 file into a disk of the image proxy virtual machine and mounting it to the image proxy virtual machine; and mounting the disk virtualized from the target qcow2 file to a specified first image directory in the image proxy virtual machine.
[0007] In some embodiments, creating a qcow2 file includes: creating a qcow2 file with a specified size and formatting the qcow2 file into a specified file system.
[0008] In some embodiments, the method further includes: adjusting the size of the qcow2 file.
[0009] In some embodiments, the method further includes: encrypting the qcow2 file.
[0010] In some embodiments, the method further includes: compressing the qcow2 file.
[0011] In a second aspect, an embodiment of the present disclosure provides an apparatus for managing container images, including: a creation unit configured to create a qcow2 file and start an image proxy virtual machine with a virtual disk of the qcow2 file; a first mounting unit configured to mount the virtual disk of the qcow2 file to a specified first image directory in the image proxy virtual machine; a pulling unit configured to pull an image from a container image source to the specified first image directory in the image proxy virtual machine; a first snapshot unit configured to take a snapshot of the qcow2 file to generate a qcow2 snapshot file; a first virtualization unit configured to start a lightweight virtual machine and virtualize the qcow2 snapshot file into a disk of the lightweight virtual machine and mount it to the lightweight virtual machine; and a second mounting unit configured to mount the disk virtualized from the qcow2 snapshot file to a specified second image directory in the lightweight virtual machine.
[0012] In some embodiments, the apparatus further includes: a pushing unit configured to push the image used by the lightweight virtual machine to a specified second image directory in the lightweight virtual machine; a second snapshot unit configured to take a snapshot of the qcow2 file in the second image directory to generate a target qcow2 file; a second virtualization unit configured to virtualize the target qcow2 file into a disk of the image proxy virtual machine and mount it to the image proxy virtual machine; and the first mounting unit is further configured to mount the disk virtualized from the target qcow2 file to a specified first image directory in the image proxy virtual machine.
[0013] In some embodiments, the creation unit is further configured to: create a qcow2 file of a specified size and format the qcow2 file into a specified file system.
[0014] In some embodiments, the apparatus further includes an adjustment unit configured to: adjust the size of the qcow2 file.
[0015] In some embodiments, the apparatus further includes an encryption unit configured to: encrypt the qcow2 file.
[0016] In some embodiments, the apparatus further includes a compression unit configured to: compress the qcow2 file.
[0017] In a third aspect, embodiments of the present disclosure provide an electronic device, including: one or more processors; a storage device having stored thereon one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the method according to any one of the first aspect.
[0018] In a fourth aspect, embodiments of the present disclosure provide a computer-readable medium having stored thereon a computer program, wherein the program, when executed by a processor, implements the method according to any one of the first aspect.
[0019] The method and apparatus for managing container images provided by the embodiments of the present disclosure utilize the widely used qcow2 technology in the management of traditional virtual machine images, combine it with existing container image methods, and implement a set of image management methods that can fully fit container engines based on lightweight virtual machines such as Kata Containers. All features of traditional virtual machines can be effectively utilized, which is also lacking in current container solutions when applied in the public cloud environment, such as speed limiting, quota, encryption, compression, live migration, online expansion, etc. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Other features, objects, and advantages of the present disclosure will become more apparent by reading the detailed description of non-limiting embodiments with reference to the following drawings:
[0021] Figure 1 is an exemplary system architecture diagram to which an embodiment of the present disclosure can be applied;
[0022] Figure 2 is a flowchart of an embodiment of the method for managing container images according to the present disclosure;
[0023] Figure 3 is a schematic diagram of an application scenario of the method for managing container images according to the present disclosure;
[0024] Figure 4 is a flowchart of yet another embodiment of the method for managing container images according to the present disclosure;
[0025] Figure 5 is a schematic structural diagram of an embodiment of the apparatus for managing container images according to the present disclosure;
[0026] Figure 6 is a schematic structural diagram of a computer system of an electronic device suitable for implementing the embodiments of the present disclosure. Detailed Embodiments
[0027] The present disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related invention and are not intended to limit the invention. Additionally, it should be noted that for the sake of description, only parts related to the relevant invention are shown in the drawings.
[0028] It should be noted that, without conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other. The present disclosure will be described in detail below with reference to the drawings and embodiments.
[0029] Figure 1 An exemplary system architecture 100 is shown in which embodiments of the method for managing container images or the apparatus for managing container images according to the present disclosure can be applied.
[0030] As Figure 1 shown, the system architecture 100 may include container image sources 101, 102, 103, a network 104, and a host 105. The network 104 is used to provide a medium for communication links between the container image sources 101, 102, 103 and the host 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0031] Users can use the container image sources 101, 102, 103 to interact with the host 105 through the network 104 to receive or send messages, etc. The container image sources 101, 102, 103 may come from different container providers.
[0032] The host 105 may be a server that provides various container services. The server can pull container images from the container image source and run containers.
[0033] It should be noted that the method for managing container images provided by the embodiments of the present disclosure is generally executed by the host 105. Correspondingly, the apparatus for managing container images is generally disposed in the host 105.
[0034] It should be understood, Figure 1The numbers of the terminal devices, networks, and servers in [it] are merely illustrative. According to the implementation requirements, there can be any number of terminal devices, networks, and servers.
[0035] Continuing to refer to Figure 2 , a flowchart 200 of an embodiment of a method for managing container images according to the present disclosure is shown. The method for managing container images includes the following steps:
[0036] Step 201, create a qcow2 file and start an image proxy virtual machine with a virtual disk of the qcow2 file.
[0037] In this embodiment, the execution subject of the method for managing container images (such as Figure 1 the shown host machine) creates a qcow2 file on the host machine. The size of the qcow2 file can be the same as the size of the system disk. And format the qcow2 file into a specified file system (such as, ext4). Qcow2 is a super image format integrating various technologies, supporting a series of functions such as internal snapshots, encryption, compression, etc., and its access performance is also constantly improving. Optionally, a qcow2 file of a specified size can be created to limit the disk quota. The present disclosure introduces an image proxy virtual machine, and the disk of the image proxy virtual machine is virtualized through the qcow2 file on the host machine. The virtual disk can be virtualized through technologies such as virtio-blk / virtio-scsi.
[0038] Step 202, mount the virtual disk of the qcow2 file to a specified first image directory in the image proxy virtual machine.
[0039] In this embodiment, the method of mounting a hard disk to a directory in the prior art can be referred to and will not be elaborated here.
[0040] Step 203, pull an image from a container image source to a specified first image directory in the image proxy virtual machine.
[0041] In this embodiment, the proxy service in the image proxy virtual machine can be notified through RPC (Remote Procedure Call) to pull an image from the container image source, and store the pulled image into a specified first image directory in the image proxy virtual machine, that is, into the directory corresponding to the disk of the qcow2 file.
[0042] Step 204, take a snapshot of the qcow2 file to generate a qcow2 snapshot file.
[0043] In this embodiment, a snapshot can save the states of the memory, disk files, etc. of a virtual machine at a certain point in time as an image file. Through this image file, the state of the virtual machine when the snapshot was created can be restored at any time in the future, which is very useful when using the virtual machine for testing. That is, the qcow2 snapshot file is an image file of the qcow2 file. Here, the snapshot adopts the copy on write method. When taking a snapshot, the current image file remains unchanged, and a new image file is created, using the original image file as a backup file, and then the virtual machine uses the new image file.
[0044] Step 205: Start the lightweight virtual machine, and virtualize the qcow2 snapshot file into the disk of the lightweight virtual machine and mount it to the lightweight virtual machine.
[0045] In this embodiment, the qcow2 snapshot file is virtualized into the disk of the lightweight virtual machine and mounted to the lightweight virtual machine through technologies such as virtio-blk / virtio-scsi. The lightweight virtual machine refers to new container engines such as Kata Containers that can endow containers with isolation comparable to traditional virtual machines, so as to be applicable to multi-tenant cloud environments such as public clouds. It uses hardware virtualization technology to isolate multi-tenants, and at the same time supports existing container standards (OCI), and is compatible with docker and kubernetes. However, container engines based on lightweight virtual machines such as Kata Containers have certain deficiencies when compatible with existing container image standards. Because container image storage is usually implemented based on a layered file system, that is, container images are presented in the form of directories on the host, and when virtual machines need to use them, they need to be passed to the virtual machine through the method of shared directories. However, the current shared directory technologies (9pfs, virtiofs) are not very perfect, and many important features, such as quota, speed limit, snapshot, online expansion, etc. are missing.
[0046] Step 206: Mount the disk virtualized from the qcow2 snapshot file to the specified second image directory in the lightweight virtual machine.
[0047] In this embodiment, the method of mounting a hard disk to a directory in the prior art can be referred to, and details are not described herein again.
[0048] Continue to refer to Figure 3 , Figure 3 is a schematic diagram of an application scenario of the method for managing container images according to this embodiment. In Figure 3In the application scenario, by introducing a mirrored proxy virtual machine, the disk of the mirrored proxy virtual machine is virtualized through a qcow2 file on the host machine. When pulling an image from a container image source, the pulling operation is executed by the proxy service within the mirrored proxy virtual machine. After the pulling is completed, the container image is saved in a certain directory on the virtual machine disk. At this time, by taking a snapshot of the qcow2 file, a qcow2 snapshot file containing the container image directory can be generated. When a container engine such as Kata Containers, which is based on a lightweight virtual machine, needs to use this image, we only need to virtualize this snapshot file into the disk of the lightweight virtual machine through technologies such as virtio-blk / virtio-scsi. Of course, we can also perform the reverse operation to push the image used by the lightweight virtual machine to the image source.
[0049] In this way, the container image in directory form is finally copied into the qcow2 file, and the qcow2 file is virtualized for use as the disk of the lightweight virtual machine. The advantage of doing this is that the image of the lightweight virtual machine is finally unified with that of the traditional virtual machine, and all features of the traditional virtual machine can be effectively utilized, which is also what is lacking in the current container solution when applied in the public cloud environment, such as speed limiting, quota, encryption, compression, live migration, online expansion, etc.
[0050] For further reference Figure 4 , it shows the flowchart 400 of another embodiment of the method for managing container images. The flowchart 400 of the method for managing container images includes the following steps:
[0051] Step 401, push the image used by the lightweight virtual machine to the specified second image directory in the lightweight virtual machine.
[0052] In this embodiment, the execution subject of the method for managing container images (such as Figure 1 the host machine shown) pushes the image used by the lightweight virtual machine on the host machine to the specified second image directory in the lightweight virtual machine. There is already a created qcow2 file in the second image directory, such as the qcow2 snapshot file in step 204, and the original qcow2 file can be overwritten with the image used by the lightweight virtual machine.
[0053] Step 402, take a snapshot of the qcow2 file in the second image directory to generate a target qcow2 file.
[0054] In this embodiment, it is basically the same as step 204, generating an image file based on the qcow2 file in the second image directory.
[0055] Step 403: Virtualize the target qcow2 file as the disk of the image proxy virtual machine and mount it to the image proxy virtual machine.
[0056] In this embodiment, virtualize the snapshot file generated in step 402 as the disk of the image proxy virtual machine and mount it to the image proxy virtual machine.
[0057] Step 404: Mount the disk virtualized from the target qcow2 file to the specified first image directory in the image proxy virtual machine.
[0058] In this embodiment, the container image source can access the snapshot file through the first image directory, that is, the container image source obtains the image used by the lightweight virtual machine.
[0059] From Figure 4 it can be seen that compared with the corresponding embodiment of Figure 2 , the process 400 of the method for managing container images in this embodiment reflects the step of pushing the image used by the virtual machine to the container image source. Thus, the solution described in this embodiment can modify the image in the container image source.
[0060] Further referring to Figure 5 , as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an apparatus for managing container images. This apparatus embodiment corresponds to the method embodiment shown in Figure 2 , and this apparatus can be specifically applied to various electronic devices.
[0061] As Figure 5 shown, the apparatus 500 for managing container images in this embodiment includes: a creation unit 501, a first mounting unit 502, a pulling unit 503, a first snapshot unit 504, a first virtualization unit 505, and a second mounting unit 506. Among them, the creation unit 501 is configured to create a qcow2 file and start an image proxy virtual machine with a virtual disk of the qcow2 file; the first mounting unit 502 is configured to mount the virtual disk of the qcow2 file to the specified first image directory in the image proxy virtual machine; the pulling unit 503 is configured to pull an image from the container image source to the specified first image directory in the image proxy virtual machine; the first snapshot unit 504 is configured to take a snapshot of the qcow2 file to generate a qcow2 snapshot file; the first virtualization unit 505 is configured to start a lightweight virtual machine and virtualize the qcow2 snapshot file as the disk of the lightweight virtual machine and mount it to the lightweight virtual machine; the second mounting unit 506 is configured to mount the disk virtualized from the qcow2 snapshot file to the specified second image directory in the lightweight virtual machine.
[0062] In this embodiment, for the creation unit 501, the first mounting unit 502, the pulling unit 503, the first snapshot unit 504, the first virtual unit 505, and the second mounting unit 506 of the device 500 for managing container images, the specific processing can refer to Figure 2 Steps 201-206 in the corresponding embodiment.
[0063] In some alternative implementation manners of this embodiment, the device 500 further includes: a pushing unit (not shown in the drawings), configured to push the image used by the lightweight virtual machine to a specified second image directory in the lightweight virtual machine; a second snapshot unit (not shown in the drawings), configured to take a snapshot of the qcow2 file in the second image directory to generate a target qcow2 file; a second virtual unit (not shown in the drawings), configured to virtualize the target qcow2 file into a disk of the image proxy virtual machine and mount it to the image proxy virtual machine; the first mounting unit is further configured to mount the disk virtualized by the target qcow2 file to a specified first image directory in the image proxy virtual machine.
[0064] In some alternative implementation manners of this embodiment, the creation unit 501 is further configured to: create a qcow2 file with a specified size and format the qcow2 file into a specified file system.
[0065] In some alternative implementation manners of this embodiment, the device 500 further includes an adjustment unit (not shown in the drawings), configured to: adjust the size of the qcow2 file.
[0066] In some alternative implementation manners of this embodiment, the device 500 further includes an encryption unit (not shown in the drawings), configured to: encrypt the qcow2 file.
[0067] In some alternative implementation manners of this embodiment, the device 500 further includes a compression unit (not shown in the drawings), configured to: compress the qcow2 file.
[0068] Next, refer to Figure 6 , which shows a schematic structural diagram of an electronic device (such as Figure 1 the host computer in) 600 suitable for implementing the embodiments of the present disclosure. Figure 6 The host computer shown is only an example and should not impose any limitations on the functions and usage scopes of the embodiments of the present disclosure.
[0069] As Figure 6As shown, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0070] Generally, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or wirelessly to exchange data. Although Figure 6 an electronic device 600 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices may be implemented or had. Figure 6 Each block shown in the figure may represent a device or, as needed, multiple devices.
[0071] In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes program code for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by a processing device 601, the above-described functions defined in the methods of embodiments of the present disclosure are performed. It should be noted that the computer-readable medium described in embodiments of the present disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of a computer-readable storage medium can include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In embodiments of the present disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable signal medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0072] The above computer-readable medium may be included in the above electronic device; or it may exist separately and not be assembled into the electronic device. The above computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device is caused to: create a qcow2 file and start an image proxy virtual machine with the virtual disk of the qcow2 file; mount the virtual disk of the qcow2 file to a first image directory specified in the image proxy virtual machine; pull an image from a container image source to the first image directory specified in the image proxy virtual machine; take a snapshot of the qcow2 file to generate a qcow2 snapshot file; start a lightweight virtual machine and virtualize the qcow2 snapshot file into the disk of the lightweight virtual machine and mount it to the lightweight virtual machine; mount the disk virtualized from the qcow2 snapshot file to a second image directory specified in the lightweight virtual machine.
[0073] Computer program code for performing the operations of the embodiments of the present disclosure may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (for example, by connecting through the Internet using an Internet service provider).
[0074] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0075] The units involved in the embodiments described in this disclosure can be implemented in software or in hardware. The described units can also be provided in a processor. For example, it can be described as: a processor includes a creation unit, a first mounting unit, a pulling unit, a first snapshot unit, a first virtual unit, and a second mounting unit. Among them, the names of these units do not constitute a limitation on the unit itself in some cases. For example, the creation unit can also be described as "the unit that creates a qcow2 file and starts an image proxy virtual machine with the virtual disk having the qcow2 file".
[0076] The above description is only for the preferred embodiments of this disclosure and the illustration of the technical principles applied. Those skilled in the art should understand that the scope of the invention involved in this disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the inventive concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) disclosed in this disclosure that have similar functions.
Claims
1. A method for managing container images, comprising: creating a qcow2 file and starting an image proxy virtual machine with the virtual disk of the qcow2 file; mounting the virtual disk of the qcow2 file to a specified first image directory in the image proxy virtual machine; pulling an image from a container image source to the specified first image directory in the image proxy virtual machine; taking a snapshot of the qcow2 file to generate a qcow2 snapshot file; starting a lightweight virtual machine and virtualizing the qcow2 snapshot file into a disk of the lightweight virtual machine and mounting it to the lightweight virtual machine; mounting the disk virtualized from the qcow2 snapshot file to a specified second image directory in the lightweight virtual machine.
2. The method according to claim 1, wherein, the method further comprises: pushing the image used by the lightweight virtual machine to the specified second image directory in the lightweight virtual machine; taking a snapshot of the qcow2 file in the second image directory to generate a target qcow2 file; virtualizing the target qcow2 file into a disk of the image proxy virtual machine and mounting it to the image proxy virtual machine; mounting the disk virtualized from the target qcow2 file to the specified first image directory in the image proxy virtual machine.
3. The method according to claim 1, wherein, the creating of the qcow2 file comprises: creating a qcow2 file of a specified size and formatting the qcow2 file into a specified file system.
4. The method according to claim 1, wherein, the method further comprises: adjusting the size of the qcow2 file.
5. The method according to claim 1, wherein, the method further comprises: encrypting the qcow2 file.
6. The method according to claim 1, wherein, the method further comprises: compressing the qcow2 file.
7. An apparatus for managing container images, comprising: a creating unit configured to create a qcow2 file and start an image proxy virtual machine with the virtual disk of the qcow2 file; a first mounting unit configured to mount the virtual disk of the qcow2 file to a specified first image directory in the image proxy virtual machine; a pulling unit configured to pull an image from a container image source to the specified first image directory in the image proxy virtual machine; a first snapshot unit configured to take a snapshot of the qcow2 file to generate a qcow2 snapshot file; a first virtualizing unit configured to start a lightweight virtual machine and virtualize the qcow2 snapshot file into a disk of the lightweight virtual machine and mount it to the lightweight virtual machine; a second mounting unit configured to mount the disk virtualized from the qcow2 snapshot file to a specified second image directory in the lightweight virtual machine.
8. The apparatus according to claim 7, wherein, the apparatus further comprises: a pushing unit configured to push the image used by the lightweight virtual machine to the specified second image directory in the lightweight virtual machine; A second snapshot unit, configured to take a snapshot of the qcow2 file in the second mirror directory to generate a target qcow2 file; A second virtual unit, configured to virtualize the target qcow2 file into a disk of the mirror proxy virtual machine and mount it to the mirror proxy virtual machine; The first mounting unit is further configured to mount the disk virtualized by the target qcow2 file to a specified first mirror directory in the mirror proxy virtual machine.
9. The apparatus according to claim 7, wherein, The creating unit is further configured to: Create a qcow2 file of a specified size and format the qcow2 file into a specified file system.
10. The apparatus according to claim 7, wherein, The apparatus further includes an adjustment unit, configured to: Adjust the size of the qcow2 file.
11. The apparatus according to claim 7, wherein, The apparatus further includes an encryption unit, configured to: Encrypt the qcow2 file.
12. The apparatus according to claim 7, wherein, The apparatus further includes a compression unit, configured to: Compress the qcow2 file.
13. An electronic device, comprising: One or more processors; A storage device having stored thereon one or more programs, When the one or more programs are executed by the one or more processors, causing the one or more processors to implement the method according to any one of claims 1-7.
14. A computer-readable medium having stored thereon a computer program, wherein, The program, when executed by a processor, implements the method according to any one of claims 1-7.
Citation Information
Patent Citations
Virtual machine configuration system
CN101470621A
Proxy backup of virtual disk image files on NAS devices
CN102576322A