Container starting method and apparatus, and electronic device and storage medium
By using Overlay FS and Virtio-fs in the Kata container to separate the read-only layer and the writable layer of the container image startup program, the problem of poor performance and loss of the writable layer when the container is started and restarted is solved, and efficient container startup is achieved. and persistence.
Patent Information
- Application Number
- PCT/CN2024/086760
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-23
- Filing Date
- 2024-04-09
- Publication Date
- 2024-10-31
AI Technical Summary
The existing Kata container image startup program has poor read and write performance through the Virtio-fs shared file system, and the writable layer content is easily lost after the container is restarted.
By responding to the pre-obtained container startup instructions, the pre-created container image startup program is mounted to the virtual machine, and the virtual machine status is detected, the container identification file is created, and hot-plugged into the specified directory of the virtual machine to realize the read-only layer and the writable layer. Separation, using Overlay FS and Virtio-fs for joint mounting to ensure the persistence of writable layer content when the container is started and restarted.
It improves the performance when starting and restarting the container, avoids the loss of content in the writable layer, and realizes the separation and persistence of the read and write layers.
Smart Images

Figure CN2024086760_31102024_PF_FP_ABST
Abstract
Description
Container startup method, device, electronic device and storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application is based on the Chinese application with application number 202310445491.X and application date April 23, 2023, and claims its priority. The disclosed content of the Chinese application is hereby introduced as a whole into this application. Technical Field
[0003] The present disclosure relates to the field of computer technology, and in particular to a container startup method, device, electronic device, and storage medium. Background Art
[0004] Currently, the container image launcher in Kata uses Virtio-fs (a shared file system) to share the container image launcher on the host machine to the virtual machine. File reading and writing within the Kata container are all done by forwarding fuse requests to the host machine through Virtio-fs.
[0005] Summary of the Invention
[0006] The present disclosure provides a container startup method, device, electronic device, and storage medium.
[0007] According to one aspect of an embodiment of the present disclosure, a container startup method is provided, the method comprising:
[0008] In response to the pre-obtained container startup instruction, the pre-created container image startup program is mounted to the virtual machine in the target container group;
[0009] Detect the current state of the virtual machine and, if the current state is in the startup state, create a container identification file for the target container group;
[0010] Hot-insert the container identification file into the virtual machine and mount it to the specified directory of the virtual machine;
[0011] In the virtual machine, the specified directory and the container image startup program are jointly mounted to obtain a first startup program, and the first startup program is run to complete the container startup operation.
[0012] According to another aspect of the present disclosure, a container starting device is provided, comprising:
[0013] A response module is used to respond to the pre-acquired container startup instruction and mount the pre-created container image startup program to the virtual machine in the target container group;
[0014] a detection module, configured to detect a current state of the virtual machine and, if the current state is a startup state, create a container identification file for the target container group;
[0015] a processing module, configured to hot-plug the container identification file into the virtual machine and mount it to a designated directory of the virtual machine;
[0016] An execution module is used to jointly mount the specified directory and the container image startup program in the virtual machine to obtain a first startup program, and run the first startup program to complete the container startup operation.
[0017] According to another aspect of an embodiment of the present disclosure, a storage medium is further provided. The storage medium includes a stored program, and the above steps are executed when the program is run.
[0018] According to another aspect of an embodiment of the present disclosure, an electronic device is also provided, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the program stored in the memory.
[0019] The embodiment of the present disclosure further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the steps in the above method. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0022] FIG1 is a schematic diagram of a Kata native container startup process provided by an embodiment of the present disclosure;
[0023] FIG2 is a schematic diagram of the working principle of Virtio-fs provided in an embodiment of the present disclosure;
[0024] FIG3 is a flow chart of a container startup method provided by an embodiment of the present disclosure;
[0025] FIG4 is a flowchart of a container startup method provided by another embodiment of the present disclosure;
[0026] FIG5 is a block diagram of a container starting device provided by an embodiment of the present disclosure;
[0027] FIG6 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] To make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. The schematic embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure.
[0029] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another similar entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device that includes the element.
[0030] Figure 1 shows the implementation process of Kata's native container startup provided in an embodiment of the present application. As shown in Figure 1, Kata needs to provide a container image startup program (container image root FS (file system)) for the container inside the virtual machine. The specific implementation process is to stack the file system on the host machine through Overlay FS, and then transparently transmit it to the container corresponding to the virtual machine through Vrtio-fs, and serve as the read-write layer of the container.
[0031] It's important to note that Overlay FS (file system) is a union file system that overlays the contents of multiple directories onto one another. Overlay FS doesn't directly involve disk space structure; it appears to merge files from multiple directories into a single directory according to rules. There are no specific file system types required for multiple source directories, and even if the file system types differ across the source directories, it still works. Using Overlay FS, a read-only underlying file system can be merged with a read-write upper file system, resulting in a file system that meets both read and write requirements while ensuring data security.
[0032] As shown in Figure 2, Virtio-fs uses the FUSE (File System in User Space) protocol for communication between the host and guest. A fuse server is implemented on the host to manipulate files on the host. The guest kernel then acts as a fuse client to mount the fuse within the guest. Virtio is used as the transport layer between the server and client to carry the FUSE protocol, rather than the traditional / dev / fuse device.
[0033] For this reason, the container image launcher in Kata uses Virtio-fs to share the container image launcher on the host machine with the virtual machine. File reads and writes within the container are forwarded to the host machine via Virtio-fs through fuse requests. However, this presents the following issues: Compared to block-based file systems, Virtio-fs-based file systems have poor read and write performance. Furthermore, containers are inherently stateless, so if the container is restarted, the contents of the container's writable layer may be lost.
[0034] Based on this, embodiments of the present disclosure provide a container startup method, apparatus, electronic device, and storage medium. The methods provided in embodiments of the present disclosure can be applied to any desired electronic device, such as a server, terminal, or other electronic device. These devices are not specifically limited here and, for ease of description, will be referred to as electronic devices.
[0035] According to one aspect of an embodiment of the present disclosure, a method embodiment of a container startup method is provided. FIG3 is a flow chart of a container startup method provided by an embodiment of the present disclosure. As shown in FIG3 , the method includes:
[0036] Step S11, in response to the pre-acquired container startup instruction, the pre-created container image startup program is mounted to the virtual machine in the target container group.
[0037] The method provided in the embodiment of the present application is applied to a container daemon (Containerd), which can receive container startup instructions issued by the container cluster through the Container Runtime Interface (CRI). Specifically, when the target container group in the container cluster needs to be started, the container daemon needs to obtain the container image startup program (container image rootfs) and mount the container identification file locally, and finally realize the container startup by jointly mounting the two, wherein the target container group is any container group (Pod) in the container cluster.
[0038] Specifically, in response to the pre-acquired container startup instruction, the pre-created container image startup program is mounted to the virtual machine in the target container group, including the following steps A1-A3:
[0039] Step A1: Get the container startup instruction.
[0040] In an embodiment of the present application, when the container cluster starts the target container group through the CRI, the container background resident program will obtain the container startup instruction issued by the container cluster.
[0041] Step A2: In response to the container startup instruction, obtain a pre-created container image startup program.
[0042] Step A3: Mount the container image startup program to the virtual machine.
[0043] In an embodiment of the present application, the container daemon responds to the container startup instruction and obtains the container image startup program created in advance using the Overlay snapshotter. The container daemon transmits the container image startup program to the virtual machine (VM) in the target container group through virtio-fs, thereby realizing the mounting of the container image startup program on the virtual machine. It can be understood that the container daemon is an implementation of CRI, which can be connected to various runtimes (such as runc, kata) through the shim of the container daemon, and can also prepare startup programs (roofts) for the startup of the container. This function is implemented by the snapshotter component in the container daemon.
[0044] It should be noted that the container is built based on a read-only layer and a writable layer. The embodiment of the present application uses a container daemon to mount the container image startup program to the virtual machine, with the purpose of using the container image startup program as the read-only layer of the container when the container is started.
[0045] Step S12: Detect the current state of the virtual machine, and if the current state is the startup state, create a container identification file of the target container group.
[0046] In an embodiment of the present application, after the container image startup program is mounted to the virtual machine, the container background resident program will receive the operating environment creation instruction and create the operating environment when the container is started based on the operating environment creation instruction, that is, the Pod Sandbox. During this process, the container background resident program will call the container background resident program Containerd-shim-kata-v2 to start the virtual machine, and then detect the current state of the virtual machine. If the current state is the startup state, it is determined that the virtual machine has been successfully started. At this time, the container identification file of the target container group is created. After the container identification file is successfully created, it indicates that the operating environment has been successfully created.
[0047] In this embodiment of the present application, creating a container identification file for a target container group includes the following steps B1-B2:
[0048] Step B1: Obtain a preset container identifier template file and a container identifier corresponding to the target container group.
[0049] Step B2: Create a container identification file corresponding to the target container group using the container identification template file and the container identification.
[0050] In the embodiment of the present application, the container daemon will call the container daemon-shim-kata-v2 to copy the container identification template file (template.qcow2 file) to the local directory / run / kata-containers / sandbox / <sandboxid> / <poduid>,qcow2, it should be noted that, since the container identification template file is a pre-created blank file, after copying it to the local directory, it is necessary to obtain the container identification of the target container group (i.e., Pod UID) and use the container identification to update the container identification file, that is, to create the container identification file corresponding to the target container group ( <poduid>.qcow2 files).
[0051] It should be noted that the target container group's container identifier is written to the container identifier template file in the local directory to obtain a container identifier file. The container identifier file can then be mounted to a specified directory on the virtual machine. This localized container identifier file provides the prerequisite for subsequently building a writable container layer. At the same time, the container identifier file can be mounted to a specified directory on the virtual machine, achieving separation between the read-only layer and the writable layer.
[0052] Step S13: hot-plug the container identification file into the virtual machine and mount it to a designated directory of the virtual machine.
[0053] In this embodiment of the present application, after creating the container identification file of the target container group, the method further includes the following steps C1-C3:
[0054] Step C1: Obtain the number of containers in the target container group and the container identifier of each container.
[0055] In this embodiment of the present application, after the container identification file is deployed on the virtual machine, a subdirectory corresponding to each container in the target container group needs to be created in the virtual machine. Specifically, the number of containers in the target container group and the container identification (Container name) of each container are first obtained.
[0056] Step C2: Create the same number of initial subdirectories as the number of containers in the specified directory of the virtual machine.
[0057] In this embodiment of the present application, in order to start each container in the target container group, it is necessary to ensure that the number of containers and subdirectories is consistent. Based on this, an initial subdirectory equal to the number of containers in the target container group is created in the specified directory. This facilitates the subsequent mounting of the container identification file of the target container group in each subdirectory.
[0058] Step C3: Use the container identifier to update the directory name of the initial subdirectory to obtain the subdirectory.
[0059] In the embodiment of the present application, after the initial subdirectories are created, a one-to-one correspondence between each initial subdirectory and a container needs to be established. In this case, the container identifier can be used as the directory name of the initial subdirectory to obtain the subdirectory corresponding to each container in the target container group.
[0060] It should be noted that using the container ID and container number to create a subdirectory not only associates the subdirectory with the container, but also facilitates subsequent joint mounting of the subdirectory with the container image startup program in the virtual machine, thus achieving read-write separation of the container.
[0061] In an embodiment of the present application, hot-plugging a container identification file into a virtual machine and mounting the container identification file to a designated directory of the virtual machine includes: hot-plugging the container identification file into the virtual machine via a preset protocol (virtio-blk protocol) and displaying it as a block device in the virtual machine. The kata-agent component within the virtual machine then formats the block device and sequentially mounts the formatted block device to various subdirectories within the designated directory.
[0062] It should be noted that by mounting block devices in sequence to each subdirectory in the specified directory, the subdirectory where the block device is mounted is used as the writable layer, which improves the capability of the writable layer and realizes the persistence of block device files in the virtual machine (that is, the persistence of the container writable layer). Even when the container is restarted, it can ensure that the content of the writable layer will not be lost.
[0063] Step S14: In the virtual machine, the specified directory and the container image startup program are jointly mounted to obtain a first startup program, and the first startup program is run to complete the container startup operation.
[0064] In an embodiment of the present application, a specified directory and a container image startup program are jointly mounted to obtain a first startup program, including: obtaining a joint mount instruction; responding to the joint mount instruction, jointly mounting the subdirectory mounted with a block device and the container image startup program to obtain the first startup program, wherein the container image startup program in the first startup program serves as a read-only layer and the subdirectory serves as a writable layer.
[0065] In an embodiment of the present application, after the container identification file is mounted to a subdirectory under a specified directory within the virtual machine, the joint mount mechanism is triggered to take effect, at which point a joint mount instruction is obtained. In response to this joint mount instruction, the container image startup program is used as the read-only layer of the container startup program, and the subdirectory where the container identification file is mounted is used as the writable layer of the container startup program, thereby obtaining a first startup program. At this point, running the first startup program within the virtual machine completes the startup of the container within the target container group.
[0066] The method provided in the embodiments of the present application uses Overlay FS+Virtio-fs to implement the container image startup program as a read-only layer, and mounts a subdirectory with a block device as a writable layer, thus achieving read-write layer separation for the container startup program. Furthermore, by using overlay to jointly mount the read-only and writable layers within the virtual machine, the poor performance of Overlay FS+virtio-FS as the read-write layer for the container startup program in the prior art is resolved. Furthermore, using the subdirectory with a block device as the writable layer allows the contents of the container's writable layer to be preserved, preventing content loss.
[0067] FIG4 is a flow chart of a container startup method provided by an embodiment of the present disclosure. As shown in FIG4 , the method further includes:
[0068] Step S21: Obtain a container restart instruction.
[0069] In an embodiment of the present application, when a container in the target container group is restarted, the container daemon detects the container restart event and generates a container restart instruction based on the container restart event.
[0070] Step S22, in response to the container restart instruction, delete the first startup program in the virtual machine, and mount the container image startup program as a read-only layer and the subdirectory as a writable layer to obtain a second startup program.
[0071] In an embodiment of the present application, the container daemon responds to a container restart instruction and deletes the first startup program currently existing in the virtual machine of the target container group. It should be noted that after the container is restarted, the read-only layer will change, so it is necessary to delete the currently existing first startup program and then re-execute the joint mount operation. Specifically, the container image startup program is used as the read-only layer, and the subdirectory mounted with the block device is used as the writable layer to obtain the second startup program. Finally, the second startup program is run to complete the container restart operation, and the writable layer does not change after the restart.
[0072] Step S23: Run the second startup program to complete the container restart operation.
[0073] In an embodiment of the present application, the container background resident program directly runs the second startup program to complete the container startup operation, thereby ensuring that the content in the corresponding writable layer will not be lost after the container is restarted.
[0074] The method provided in the embodiment of the present application uses a block device to save the contents of the container's writable layer. After the container is restarted, the contents of the read-only layer are replaced. The read-only layer and the writable layer are re-jointly mounted in the virtual machine through overlay, thereby ensuring that the writable layer will not be lost when the container is restarted.
[0075] According to one aspect of the present disclosure, a method embodiment of a container startup method is provided. The implementation process is as follows:
[0076] In step (1), use the overlay snapshotter to create a container image startup program and transparently transmit it to the virtual machine in the target container group through Virtio-fs as a read-only layer of the container startup program.
[0077] Step (2), after the virtual machine is started, Containerd-shim-kata-v2 copies the container identification template file (template.qcow2) and creates the container identification file corresponding to the target container group ( <poduid>.qcow2).
[0078] Step (3), Containerd-shim-kata-v2 connects to the hypervisor interface through the qmp interface and passes the container identification file ( <poduid>.qcow2) is hot-plugged into the virtual machine and appears as a block device.
[0079] In step (4), the kata-agent in the virtual machine formats the block device hot-plugged in step (3) and mounts it to the specified directory, and creates a subdirectory named after the container identifier in the target container group.
[0080] In step (5), the kata-agent in the virtual machine uses the container image startup program as the read-only layer and the subdirectory in step (4) as the writable layer, and mounts the Overlay FS through the overlay joint as the final container startup program of the container.
[0081] Step (6), when the container is restarted, execute step (5), because the container identification file ( <poduid>.qcow2) is persisted in the virtual machine, so restarting the container does not affect its contents, which means that the container's writable layer has persistence capabilities.
[0082] Figure 5 is a block diagram of a container startup device provided by an embodiment of the present disclosure. The device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. As shown in Figure 5, the device includes:
[0083] A response module 51 is configured to respond to a pre-acquired container startup instruction and mount a pre-created container image startup program to a virtual machine in a target container group;
[0084] A detection module 52 is configured to detect the current state of the virtual machine and, if the current state is a startup state, create a container identification file for the target container group;
[0085] Processing module 53, used to hot-insert the container identification file into the virtual machine and mount it to a designated directory of the virtual machine;
[0086] The execution module 54 is used to jointly mount the specified directory and the container image startup program in the virtual machine to obtain the first startup program, and run the first startup program to complete the container startup operation.
[0087] In an embodiment of the present application, the response module 51 is used to obtain a container startup instruction; in response to the container startup instruction, obtain a pre-created container image startup program; and mount the container image startup program to the virtual machine.
[0088] In the embodiment of the present application, the detection module 52 is configured to obtain a preset container identification template file and a container identification corresponding to the target container group; and create a container identification file corresponding to the target container group using the container identification template file and the container identification.
[0089] In an embodiment of the present application, the container startup device also includes: a creation module, which is used to obtain the container number of containers in the target container group and the container identifier of each container; create an initial subdirectory with the same number of containers as the number of containers under the specified directory of the virtual machine; and use the container identifier to update the directory name of the initial subdirectory to obtain a subdirectory.
[0090] In an embodiment of the present application, the processing module 53 is used to hot-plug the container identification file into the virtual machine through a preset protocol, and display it as a block device under the virtual machine; the block device is mounted to each subdirectory in the specified directory in sequence.
[0091] In an embodiment of the present application, the execution module 54 is used to obtain a joint mount instruction; in response to the joint mount instruction, the subdirectory mounted with the block device and the container image startup program are jointly mounted to obtain a first startup program, wherein the container image startup program in the first startup program serves as a read-only layer and the subdirectory serves as a writable layer.
[0092] In an embodiment of the present application, the container startup device also includes: a restart module, which is used to obtain a container restart instruction; in response to the container restart instruction, delete the first startup program in the virtual machine, and mount the container image startup program as a read-only layer and the subdirectory as a writable layer to obtain a second startup program; run the second startup program to complete the container restart operation.
[0093] An embodiment of the present disclosure also provides an electronic device, as shown in Figure 6, which may include: a processor 1501, a communication interface 1502, a memory 1503 and a communication bus 1504, wherein the processor 1501, the communication interface 1502, and the memory 1503 communicate with each other through the communication bus 1504.
[0094] Memory 1503, used for storing computer programs;
[0095] The processor 1501 is configured to implement the steps of the above embodiment when executing the computer program stored in the memory 1503 .
[0096] The communication bus mentioned in the terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0097] The communication interface is used for communication between the above terminal and other devices.
[0098] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0099] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0100] In another embodiment provided by the present disclosure, a computer-readable storage medium is further provided. The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the container startup method described in any one of the above embodiments.
[0101] In another embodiment provided by the present disclosure, a computer program product including instructions is further provided, which, when executed on a computer, enables the computer to execute the container startup method described in any one of the above embodiments.
[0102] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present disclosure is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD (Digital Versatile Disc)), or a semiconductor medium (eg, a solid state disk).
[0103] The above description is only a preferred embodiment of the present disclosure and is not intended to limit the scope of protection of the present disclosure. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present disclosure are included in the scope of protection of the present disclosure.
[0104] The foregoing description is intended only to provide specific embodiments of the present disclosure, which will enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments shown herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.< / poduid> < / poduid> < / poduid> < / poduid> < / poduid> < / sandboxid>
Claims
1. A container startup method, the method comprising: In response to the pre-acquired container startup instruction, the pre-created container image startup program is mounted to the virtual machine in the target container group; Detecting a current state of the virtual machine, and creating a container identification file of the target container group when the current state is a startup state; Hot-plugging the container identification file into the virtual machine and mounting it to a designated directory of the virtual machine; In the virtual machine, the designated directory and the container image startup program are jointly mounted to obtain a first startup program, and the first startup program is run to complete the container startup operation.
2. The method according to claim 1, wherein: The step of responding to the pre-acquired container startup instruction and mounting the pre-created container image startup program to the virtual machine in the target container group includes: Get the container startup instruction; In response to the container startup instruction, obtaining a pre-created container image startup program; Mount the container image startup program to the virtual machine.
3. The method according to claim 1 or 2, wherein: The step of creating a container identification file of the target container group includes: Obtaining a preset container identifier template file and a container identifier corresponding to the target container group; A container identification file corresponding to the target container group is created using the container identification template file and the container identification.
4. The method according to any one of claims 1 to 3, wherein: After creating the container identification file of the target container group, the method further includes: Obtaining the number of containers in the target container group and a container identifier of each container; Under the specified directory of the virtual machine, create the same number of initial subdirectories as the number of containers; The directory name of the initial subdirectory is updated using the container identifier to obtain a subdirectory.
5. The method according to claim 4, wherein: The hot-plugging the container identification file into the virtual machine and mounting it to a designated directory of the virtual machine includes: Hot-plugging the container identification file into the virtual machine through a preset protocol, and displaying it as a block device under the virtual machine; The block devices are mounted sequentially to each subdirectory in the specified directory.
6. The method according to claim 5, wherein: The step of jointly mounting the designated directory and the container image startup program to obtain a first startup program includes: Get the joint mount command; In response to the joint mount instruction, the subdirectory mounted with the block device and the container image startup program are jointly mounted to obtain a first startup program, wherein the container image startup program in the first startup program serves as a read-only layer and the subdirectory serves as a writable layer.
7. The method according to any one of claims 1 to 6, further comprising: Get container restart instructions; In response to the container restart instruction, the first startup program in the virtual machine is deleted, and the container image startup program is used as a read-only layer, and the subdirectory is mounted as a writable layer to obtain the second startup program; Run the second startup program to complete the container restart operation.
8. A container starting device, comprising: A response module, used to respond to the pre-acquired container startup instruction and mount the pre-created container image startup program to the virtual machine in the target container group; A detection module, used to detect a current state of the virtual machine, and create a container identification file of the target container group when the current state is a startup state; A processing module, used for hot-plugging the container identification file into the virtual machine and mounting it to a designated directory of the virtual machine; An execution module is used to jointly mount the specified directory and the container image startup program in the virtual machine to obtain a first startup program, and run the first startup program to complete the container startup operation.
9. A storage medium comprising a stored program, wherein: When the program is executed, the method steps described in any one of claims 1 to 7 are executed.
10. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein: The processor, the communication interface, and the memory communicate with each other via a communication bus; wherein: Memory, used to store computer programs; A processor, configured to execute the method steps of any one of claims 1 to 7 by running a program stored in a memory.
11. A computer program product comprising instructions, which, when executed on a computer, cause the computer to perform the method steps of any one of claims 1 to 7.
12. A computer program comprising instructions, which, when executed on a computer, cause the computer to execute the method steps of any one of claims 1 to 7.
Citation Information
Patent Citations
Container starting method, system, device and equipment
CN114217908A
Container starting method and device, computer equipment and storage medium
CN114860344A
Container starting method and device, electronic equipment and storage medium
CN116483514A
Cited By
Method and device for optimizing starting speed of cloud application
CN119376819A
Business program execution method and device, embedded equipment and medium
CN120704758A
