CN111782339A - Container creation method and device, electronic equipment and storage medium - Google Patents

Container creation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111782339A
CN111782339A CN202010597813.9A CN202010597813A CN111782339A CN 111782339 A CN111782339 A CN 111782339A CN 202010597813 A CN202010597813 A CN 202010597813A CN 111782339 A CN111782339 A CN 111782339A
Authority
CN
China
Prior art keywords
virtual machine
directory
file
new agent
container
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.)
Granted
Application number
CN202010597813.9A
Other languages
Chinese (zh)
Other versions
CN111782339B (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.)
JD Digital Technology Holdings Co Ltd
Original Assignee
JD Digital Technology Holdings 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 JD Digital Technology Holdings Co Ltd filed Critical JD Digital Technology Holdings Co Ltd
Priority to CN202010597813.9A priority Critical patent/CN111782339B/en
Publication of CN111782339A publication Critical patent/CN111782339A/en
Application granted granted Critical
Publication of CN111782339B publication Critical patent/CN111782339B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • 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
    • G06F2009/45562Creating, deleting, cloning virtual machine instances

Abstract

The application provides a container creating method and device, electronic equipment and a storage medium, and belongs to the technical field of containers. The method comprises the following steps: responding to a container creating instruction, and acquiring a new agent file to be updated; and mounting the new agent side file to a first virtual machine directory in the virtual machine, so that the virtual machine can obtain the new agent side file according to the first virtual machine directory and operate a container based on the new agent side file. By adopting the technical scheme provided by the application, the problem that the container in the running state cannot run normally when a new container is created based on the existing container image file updating mode can be solved.

Description

Container creation method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of container technologies, and in particular, to a container creation method and apparatus, an electronic device, and a storage medium.
Background
The electronic device may store a container image file therein, create a virtual machine, and create a container in the virtual machine based on the container image file. In order to distinguish a virtual machine from an electronic device, the electronic device on which the virtual machine is created is referred to as a physical host, and the container image file is stored in the electronic device, that is, in the physical host.
In the related art, the electronic device may update the container image file, and create a new container based on the updated container image file, so as to update the functions of the container. The container image file includes a resource file and a kata-agent file required for creating the container, and in general, the container image file is updated, i.e., the kata-agent file in the container image is updated. The process of updating the kata-agent file by the electronic device may include: and the original container image file in the physical host is changed into a new container image file.
However, for a container in a running state during the update process of the container image file, if the original container image file is directly replaced, the virtual machine where the container is located cannot transmit data with the physical host, so that the container cannot run normally.
Disclosure of Invention
An object of the embodiments of the present application is to provide a container creation method and apparatus, an electronic device, and a storage medium, so as to solve a problem that a container in a running state cannot run normally when a new container is created based on an existing container image file update method. The specific technical scheme is as follows:
in a first aspect, the present application provides a container creating method, where the method is applied to a physical host, where a virtual machine is deployed in the physical host, and the method includes:
responding to a container creating instruction, and acquiring a new agent file to be updated;
and mounting the new agent side file to a first virtual machine directory in the virtual machine, so that the virtual machine can obtain the new agent side file according to the first virtual machine directory and operate a container based on the new agent side file.
Optionally, the mounting the new agent file to a first virtual machine directory in the virtual machine includes:
mounting the new agent side file to a container resource directory corresponding to the virtual machine to obtain a host directory of the new agent side file in the container resource directory;
mapping the host directory to a first one of the virtual machines.
Optionally, the mapping the host directory to a first virtual machine directory in the virtual machines includes:
mapping the host directory to a first one of the virtual machines based on a directory sharing file system.
In a second aspect, the present application further provides a container creation method, where the method is applied to a virtual machine deployed in a physical host, and the method includes:
in response to the fact that the physical host mounts a new agent file to be updated to a first virtual machine directory in the virtual machine, acquiring the new agent file according to the first virtual machine directory;
and running a container based on the new agent side file.
Optionally, the running the container based on the new agent file includes:
mounting the new agent side file into a root file system of the virtual machine to obtain a second virtual machine directory;
acquiring the new agent file according to the second virtual machine directory;
and executing the new agent file to create a container.
Optionally, after the new agent file is mounted to the root file system of the virtual machine and a second virtual machine directory is obtained, the method further includes:
and uninstalling the first virtual machine directory.
In a third aspect, the present application further provides a container creating apparatus, where the apparatus is applied to a physical host, where a virtual machine is deployed in the physical host, and the apparatus includes:
the acquisition module is used for responding to the container creation instruction and acquiring a new agent file to be updated;
and the mounting module is used for mounting the new agent file to a first virtual machine directory in the virtual machine so that the virtual machine can obtain the new agent file according to the first virtual machine directory and operate a container based on the new agent file.
Optionally, the mount module includes:
the mounting submodule is used for mounting the new agent side file to a container resource directory corresponding to the virtual machine to obtain a host directory of the new agent side file under the container resource directory;
and the mapping submodule is used for mapping the host directory to a first virtual machine directory in the virtual machine.
Optionally, the mapping sub-module is configured to map the host directory to a first virtual machine directory in the virtual machines based on a directory shared file system.
In a fourth aspect, the present application further provides a container creation apparatus, which is applied to a virtual machine deployed in a physical host, and includes:
the acquisition module is used for responding to the fact that the physical host mounts a new agent file to be updated to a first virtual machine directory in the virtual machine, and acquiring the new agent file according to the first virtual machine directory;
and the operation module is used for operating the container based on the new agent side file.
Optionally, the operation module includes:
the mounting submodule is used for mounting the new agent side file into a root file system of the virtual machine to obtain a second virtual machine directory;
the obtaining submodule is used for obtaining the new agent side file according to the second virtual machine directory;
and the execution submodule is used for executing the new agent side file to create a container.
Optionally, the operation module further includes:
and the unloading submodule is used for unloading the first virtual machine directory.
In a fifth aspect, the present application further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor adapted to perform the method steps of any of the first aspect or any of the second aspect when executing a program stored in the memory.
In a sixth aspect, the present application further provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the method steps of any of the first aspects, or any of the second aspects.
In a seventh aspect, there is provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method steps of any of the first aspects, or any of the second aspects, described above.
The embodiment of the application has the following beneficial effects:
the embodiment of the application provides a container creating method and device, electronic equipment and a storage medium, wherein a physical host can respond to a container creating instruction to obtain an agent file to be updated, and then the physical host can mount the new agent file to a first virtual machine directory in a virtual machine, so that the virtual machine can obtain the new agent file according to the first virtual machine directory and operate a container based on the new agent file.
Because the container image file stored in the physical host does not need to be replaced, the update of the agent file can be realized, and therefore, in the update process of the container image file, the virtual machine can normally transmit data with the physical host, and the container can normally run.
Of course, not all advantages described above need to be achieved at the same time in the practice of any one product or method of the present application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without inventive exercise.
Fig. 1 is a flowchart of a container creating method according to an embodiment of the present application;
fig. 2 is a flowchart of another container creating method provided in an embodiment of the present application;
fig. 3 is a flowchart of another container creating method provided in an embodiment of the present application;
fig. 4 is a flowchart of another container creating method provided in an embodiment of the present application;
FIG. 5 is an exemplary diagram of a method for creating a container according to an embodiment of the present application;
fig. 6 is a schematic flowchart of updating a container image file according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of a container creating apparatus according to an embodiment of the present application;
FIG. 8 is a schematic diagram of another container creating apparatus provided in the embodiments of the present application;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a container creation method, which can be applied to a physical host, wherein the physical host can be any electronic device with a virtual machine. The physical host may have a container image file stored therein, and the physical host may create a container in the virtual machine based on the container image file.
In the embodiment of the present application, one virtual machine may be deployed in the physical host, or a plurality of virtual machines may be deployed in the physical host. When a plurality of virtual machines are deployed in a physical host, the physical host may update a container image file in the virtual machine by using the container creation method provided in the embodiment of the present application for each virtual machine, and create a container based on the updated container image file.
A container creation method provided in the embodiments of the present application will be described in detail below with reference to specific embodiments, as shown in fig. 1, and includes the following specific steps:
step 101, responding to a container creating instruction, and acquiring a new agent file to be updated.
In implementation, when the container image file needs to be updated, a developer may store a new agent file to be updated in the physical host, and then, the developer may perform a preset action, so that the physical host detects a container creation instruction. The preset action may be inputting a command code indicating updating the container image file, or clicking an update icon indicating updating the container image file in the preset control page.
In response to the container creation instruction, the physical host may obtain the new agent file to be updated in a variety of ways.
In a feasible implementation manner, the new agent file may be stored in the physical host, the container creation instruction may carry a storage address of the new agent file in the physical host, and the physical host may read the new agent file according to the storage address. In another possible implementation manner, the new agent file may be stored in a preset database, the container creation instruction may carry a file identifier of the new agent file, and the physical host may obtain the new agent file from the preset database according to the file identifier.
And 102, mounting the new agent side file to a first virtual machine directory in the virtual machine.
In an implementation, the physical host may determine a virtual machine to be subject to a container image file update.
In the embodiment of the application, when the number of the virtual machines is 1, the virtual machine is a virtual machine to be subjected to updating of the container image file. When the number of the virtual machines is multiple, the physical host may determine the virtual machine to be subjected to the update of the container image file in multiple ways.
In a feasible implementation manner, the container creation instruction may carry a target virtual machine identifier, where the target virtual machine identifier is an identifier of a virtual machine to be subjected to updating of the container image file. The physical host may determine, according to the target virtual machine identifier, a virtual machine to be subjected to update of the container image file among the deployed multiple virtual machines. In another feasible implementation manner, the physical host may store a corresponding relationship between the container and the virtual machine, and the physical host may determine the virtual machine in which the container is deployed according to the corresponding relationship, and then the physical host may use the determined virtual machine as the virtual machine to be subjected to the update of the container image file.
After determining the virtual machine that needs to update the container image file, the physical host may mount the new agent file to the first virtual machine directory in the virtual machine for the determined virtual machine, and a detailed description will be made later on a specific mounting process.
Then, the virtual machine may update the container image file based on the new agent file, and the detailed processing procedure will be described later.
In this embodiment of the application, the physical host may obtain the agent file to be updated in response to the container creation instruction, and then the physical host may mount the new agent file to a first virtual machine directory in the virtual machine, so that the virtual machine obtains the new agent file according to the first virtual machine directory, and runs the container based on the new agent file.
Because the update of the agent file can be realized without replacing the container mirror image file stored in the physical host, the virtual machine can normally transmit data with the physical host and the container can normally run in the update process of the agent file.
Optionally, for each virtual machine, the physical host may store a container resource directory corresponding to the virtual machine. Under the container resource directory, a file or a directory of required files required by the virtual machine starting container can be loaded, and the file required by the virtual machine starting container is, for example: root file system (root file system) of a container.
The physical host may mount the new agent file to a first virtual machine directory of the virtual machine based on the container resource directory corresponding to the virtual machine, as shown in fig. 2, where the specific processing procedure includes:
step 201, mounting the new agent file to a container resource directory corresponding to the virtual machine, and obtaining a host directory of the new agent file in the container resource directory.
In implementation, the physical host may mount the new agent file to a container resource directory corresponding to the virtual machine, and obtain a directory of the new agent file in the container resource directory, that is, a host directory of the new agent file in the physical host.
For example, the new agent file to be updated is kata-agent, the identifier of the virtual machine to be subjected to the update of the container image file is de0eb57 effbe, and the container resource directory corresponding to the virtual machine in the physical host is/run/kata-associates/shared/sandboxes/de 0eb57 effbe.
The physical host may mount the new agent file kata-agent to a container resource directory/run/kata-associates/shared/sandboxes/de 0eb57 effbe corresponding to the virtual machine, so as to obtain a directory of the new agent file in the container resource directory, that is, the host directory is: /run/kata-associates/shared/sandboxes/de 0eb57 effbe/kata-agent.
Step 202, mapping the host directory to a first virtual machine directory in the virtual machines.
In an implementation, a physical host may map a host directory to be under a first one of the virtual machines. Therefore, the virtual machine can acquire the new agent file based on the mapped first virtual machine directory and run the container based on the new agent file. The process of the virtual machine obtaining the new agent file based on the first virtual machine directory will be described in detail later.
Optionally, the physical host may map the host directory to any non-system directory in the virtual machine, for example, the physical host may map the host directory to any/tmp directory in the virtual machine, i.e., the first virtual machine directory may be/tmp.
Or, the physical host may map the host directory to a preset directory in the virtual machine, for example, the virtual machine stores a preset directory/run/kata-contacts/shared/contacts, and the resource files required for starting the container are all loaded in the preset directory. The physical host may map the host directory to the preset directory, that is, the first virtual machine directory is/run/kata-contacts/shared/contacts.
In this embodiment of the application, the physical host may mount the new agent file to the container resource directory corresponding to the virtual machine to obtain a host directory, and then map the host directory to the first virtual machine directory in the virtual machine. Because the new agent file is mounted to the first virtual machine directory of the virtual machine based on the container resource directory corresponding to the virtual machine, the physical host can conveniently and quickly transfer the new agent file to the virtual machine.
Optionally, an embodiment of the present application further provides an implementation manner in which a physical host maps a host directory to a first virtual machine directory in a virtual machine, where the implementation manner includes: the host directory is mapped to a first one of the virtual machines based on the directory-shared file system. The directory sharing file system may be 9pfs (plan 9file system, 9 project file system), virtio-fs.
Because the host directory is mapped to the first virtual machine directory in the virtual machine based on the directory sharing system, the virtual machine can access the new agent side file mounted under the host directory by accessing the first virtual machine directory, thereby realizing data sharing between the physical host and the virtual machine.
Optionally, the physical host may also select another manner to perform data sharing with the virtual machine, for example, the physical host may mount the container image file stored in the physical host into the virtual machine based on the nvidmm characteristic of the kernel, and use the container image file as a block device mounted in the virtual machine.
Based on the same technical concept, the embodiment of the application also provides a container creation method, and the method can be applied to virtual machines deployed in a physical host.
A detailed description will be given below of a container creation method provided in the embodiments of the present application with reference to specific embodiments, as shown in fig. 3, the specific steps are as follows:
step 301, in response to the physical host mounting a new agent file to be updated to a first virtual machine directory in the virtual machine, obtaining the new agent file according to the first virtual machine directory.
Wherein, the new agent file is acquired by the physical host in response to the container creation instruction.
In implementation, when the container image file needs to be updated, the physical host may obtain a new agent file in response to the container creation instruction, and mount the new agent file in the first virtual machine directory in the virtual machine, where the specific processing process may refer to the processing processes in step 101 to step 102, and details are not described here.
After the physical host mounts the new agent file to the first virtual machine directory, the virtual machine may obtain the first virtual machine directory, and then the virtual machine may obtain the new agent file to be updated from the physical host according to the first virtual machine directory.
Optionally, the virtual machine may obtain the first virtual machine directory in multiple ways, and in a feasible implementation manner, the first virtual machine directory is a preset directory in the virtual machine, and the virtual machine may obtain the first virtual machine directory stored in advance locally. In another possible implementation, the physical host may send the first virtual machine directory to the virtual machine after mapping the host directory into the virtual machine.
Step 302, the container is operated based on the new agent side file.
In implementation, the virtual machine may run the container based on the new agent file in various ways, and in a feasible implementation manner, the virtual machine may mount the new agent file in a root file system of the virtual machine, and then implement creation and management of the container by executing the new agent file mounted in the root file system.
Or the virtual machine may directly execute the new agent file acquired according to the first virtual machine directory, thereby implementing creation and management of the container.
In this embodiment of the application, in response to the physical host mounting a new agent file to be updated to a first virtual machine directory in the virtual machine, the virtual machine may obtain the new agent file according to the first virtual machine directory, and then the virtual machine may run a container based on the new agent file. Because the update of the agent file can be realized without changing the container mirror image file stored in the physical host, the virtual machine can normally transmit data with the electronic equipment and the container can normally run in the update process of the agent file.
Optionally, an embodiment of the present application further provides an implementation manner for creating a container based on a new agent file, as shown in fig. 4, including the following steps:
step 401, mount the new agent file to the root file system of the virtual machine, and obtain a second virtual machine directory.
In implementation, the virtual machine may mount the new agent file to a root file system of the virtual machine, so as to obtain the second virtual machine directory.
For example, the virtual machine may mount the new agent end file kata-agent to the root file system of the virtual machine, resulting in a second virtual machine directory/usr/bin/kata-agent.
And step 402, acquiring a new agent file according to the second virtual machine directory.
Step 403, executing the new agent file to create a container.
The process of the virtual machine executing the new agent file to create the container is similar to the process of the virtual machine executing the kata-agent file to create the container in the related art, and details are not repeated here.
In this embodiment of the application, the virtual machine may mount the new agent file to a root file system of the virtual machine to obtain a second virtual machine directory. The virtual machine may then retrieve the new broker file from the second virtual machine directory, after which the virtual machine may execute the new broker file to create the container. Therefore, the container can be created based on the updated new agent file.
Optionally, after obtaining the second virtual machine directory, the virtual machine may further uninstall the first virtual machine directory.
For example, after the new agent-side file kata-agent is mounted into the root file system of the virtual machine, the virtual machine may unload the first virtual machine directory/run/kata-contacts/shared/contacts/.
In the embodiment of the application, the virtual machine mounts the new agent file into the root file system of the virtual machine and unloads the first virtual machine directory, so that the problem that the new agent file cannot be accessed due to repeated mounting of the new agent file can be avoided, and the updating stability of the new agent file is improved.
Optionally, an example diagram for updating a container image file provided in an embodiment of the present application is shown in fig. 5, and includes the following steps:
step 501, the physical host responds to the container creation instruction to acquire a new agent file to be updated.
In the implementation, the processing procedure of this step may refer to the processing procedure of step 101, and is not described herein again.
Step 502, the physical host mounts the new agent file to the container resource directory corresponding to the virtual machine, and obtains a host directory of the new agent file in the container resource directory.
In implementation, the processing procedure of this step may refer to the processing procedure of step 201, and is not described herein again.
Step 503, the physical host maps the host directory to a first virtual machine directory in the virtual machines based on the directory sharing file system.
Step 504, the virtual machine obtains a new agent file according to the first virtual machine directory.
In implementation, the processing procedure of this step may refer to the processing procedure of step 301, and is not described herein again.
And 505, the virtual machine mounts the new agent file into a root file system of the virtual machine to obtain a second virtual machine directory.
In implementation, the processing procedure of this step may refer to the processing procedure of step 401, and is not described herein again.
Step 506, the virtual machine obtains the new agent file according to the second virtual machine directory.
Step 507, the virtual machine executes the new agent file to create a container.
Optionally, as shown in fig. 6, a schematic flow chart of updating a container image file provided in this embodiment of the present application is shown, where 610 denotes a physical host, 620 denotes a virtual machine, kata-containers.
When configuring the virtual machine 620, the physical host 610 may mount the container image file kata-containers, img, into the virtual machine 620 based on nvidmm characteristics of the kernel, as a block device mounted to the virtual machine 620, which may be denoted as/dev/pmem 0p 1. After the virtual machine 620 is started, the kernel is started, and then the kernel can mount/dev/pmem 0p1 into the virtual machine as the rootfs (root file system) of the virtual machine. That is, the directory of the container image file kata-contacts.img is set as the root directory of the virtual machine 620, and the program script included in the container image file kata-contacts.img is executed in the virtual machine 620 in accordance with the root directory.
If the container image file needs to be updated, the physical host 610 may mount the new agent end file kata-agent to be updated to the container resource directory/run/kata-associates/shared/$ site corresponding to the virtual machine in a bind mount manner through the kata-run, to obtain the host directory/run/kata-associates/shared/sid/kata-agent. Physical host 610 may then map the host directory to the first virtual machine directory/run/kata-contacts/shared/contacts in virtual machine vm through directory-shared file system 9 pfs.
During the running of the virtual machine, the kernel will start the system d process, and the system d process can execute step S1 to pull the preinit process. The preinit process may perform step S2, accessing the new agent file kata-agent under the first virtual machine directory/run/kata-associates/shared/associates. Then, the preinit process may execute step S3 to copy the new agent end file kata-agent to the second virtual machine directory/usr/bin. Thereafter, the system process may run the kata-agent program by executing the kata-agent file, and the physical host 610 may perform step S4, commanding the kata-agent program to perform container creation through the kata-runtime, grpc api. The kata-agent program may perform step S5 to create a container in virtual machine 620.
Optionally, an embodiment of the present application further provides a method for updating a container image file, including: the physical host can decompress the locally stored container image file to obtain a decompressed directory when the virtual machine is configured. The physical host may then map the decompressed directory into the virtual machine based on the directory-shared file system, after which the physical host may set the decompressed directory as the root file system of the virtual machine. For the convenience of distinguishing, the agent file contained in the container image file is called an original agent file, and the agent file to be updated is called a new agent file.
Subsequently, when updating the container image file, the physical host may map the new agent file into the virtual machine based on the directory-shared file system. The virtual machine may then replace the primary proxy file in the decompressed directory with a new proxy file.
Based on the same technical concept, the present application further provides a container creating apparatus, where the apparatus is applied to a physical host, and a virtual machine is deployed in the physical host, as shown in fig. 7, and the apparatus includes:
an obtaining module 710, configured to obtain, in response to a container creation instruction, a new agent file to be updated;
the mounting module 720 is configured to mount the new agent file to a first virtual machine directory in the virtual machine, so that the virtual machine obtains the new agent file according to the first virtual machine directory, and runs a container based on the new agent file.
Optionally, the mount module includes:
the mounting submodule is used for mounting the new agent side file to a container resource directory corresponding to the virtual machine to obtain a host directory of the new agent side file under the container resource directory;
and the mapping submodule is used for mapping the host directory to a first virtual machine directory in the virtual machine.
Optionally, the mapping sub-module is configured to map the host directory to a first virtual machine directory in the virtual machines based on a directory shared file system.
In this embodiment of the application, the physical host may obtain the agent file to be updated in response to the container creation instruction, and then the physical host may mount the new agent file to a first virtual machine directory in the virtual machine, so that the virtual machine obtains the new agent file according to the first virtual machine directory, and runs the container based on the new agent file.
Because the container image file stored in the physical host does not need to be replaced, the update of the agent file can be realized, and therefore, in the update process of the container image file, the virtual machine can normally transmit data with the physical host, and the container can normally run.
Based on the same technical concept, the present application further provides a container creation apparatus, which is applied to a virtual machine deployed in a physical host, as shown in fig. 8, and includes:
an obtaining module 810, configured to respond to that the physical host mounts a new agent file to be updated to a first virtual machine directory in the virtual machine, and obtain the new agent file according to the first virtual machine directory;
and an executing module 820, configured to execute a container based on the new agent file.
Optionally, the operation module includes:
the mounting submodule is used for mounting the new agent side file into a root file system of the virtual machine to obtain a second virtual machine directory;
the obtaining submodule is used for obtaining the new agent side file according to the second virtual machine directory;
and the execution submodule is used for executing the new agent side file to create a container.
Optionally, the operation module further includes:
and the unloading submodule is used for unloading the first virtual machine directory.
In this embodiment of the application, in response to the physical host mounting a new agent file to be updated to a first virtual machine directory in the virtual machine, the virtual machine may obtain the new agent file according to the first virtual machine directory, and then the virtual machine may run a container based on the new agent file. Because the update of the agent file can be realized without changing the container mirror image file stored in the physical host, the virtual machine can normally transmit data with the electronic equipment and the container can normally run in the update process of the agent file.
Based on the same technical concept, the embodiment of the present application further provides an electronic device, as shown in fig. 9, including a processor 901, a communication interface 902, a memory 903 and a communication bus 904, where the processor 901, the communication interface 902, and the memory 903 are configured to communicate with each other through the communication bus 904,
a memory 903 for storing computer programs;
the processor 901 is configured to implement any of the above container creation method steps executed by the physical host or any of the above container creation method steps executed by the virtual machine when executing the program stored in the memory 903.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
In yet another embodiment provided by the present application, there is further provided a computer-readable storage medium having stored therein a computer program, which when executed by a processor, implements the steps of any of the above-described container creation methods.
In yet another embodiment provided by the present application, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform any of the container creation methods of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may 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 loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is merely exemplary of the present application and is presented to enable those skilled in the art to understand and practice the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A container creation method is applied to a physical host, wherein a virtual machine is deployed in the physical host, and the method comprises the following steps:
responding to a container creating instruction, and acquiring a new agent file to be updated;
and mounting the new agent side file to a first virtual machine directory in the virtual machine, so that the virtual machine can obtain the new agent side file according to the first virtual machine directory and operate a container based on the new agent side file.
2. The method of claim 1, wherein the mounting the new agent side file to a first virtual machine directory in the virtual machine comprises:
mounting the new agent side file to a container resource directory corresponding to the virtual machine to obtain a host directory of the new agent side file in the container resource directory;
mapping the host directory to a first one of the virtual machines.
3. The method of claim 2, wherein mapping the host directory to a first one of the virtual machines comprises:
mapping the host directory to a first one of the virtual machines based on a directory sharing file system.
4. A container creation method applied to a virtual machine deployed in a physical host, the method comprising:
in response to the fact that the physical host mounts a new agent file to be updated to a first virtual machine directory in the virtual machine, acquiring the new agent file according to the first virtual machine directory;
and running a container based on the new agent side file.
5. The method of claim 4, wherein the running the container based on the new agent side file comprises:
mounting the new agent side file into a root file system of the virtual machine to obtain a second virtual machine directory;
acquiring the new agent file according to the second virtual machine directory;
and executing the new agent file to create a container.
6. The method according to claim 5, wherein after the mounting the new agent file to a root file system of the virtual machine and obtaining a second virtual machine directory, further comprising:
and uninstalling the first virtual machine directory.
7. A container creation apparatus applied to a physical host in which a virtual machine is deployed, the apparatus comprising:
the acquisition module is used for responding to the container creation instruction and acquiring a new agent file to be updated;
and the mounting module is used for mounting the new agent file to a first virtual machine directory in the virtual machine so that the virtual machine can obtain the new agent file according to the first virtual machine directory and operate a container based on the new agent file.
8. A container creation apparatus, applied to a virtual machine deployed in a physical host, the apparatus comprising:
the acquisition module is used for responding to the fact that the physical host mounts a new agent file to be updated to a first virtual machine directory in the virtual machine, and acquiring the new agent file according to the first virtual machine directory;
and the operation module is used for operating the container based on the new agent side file.
9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1 to 3, or claims 4 to 6, when executing a program stored in a memory.
10. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of claims 1-3 or any of claims 4-6.
CN202010597813.9A 2020-06-28 2020-06-28 Container creation method and device, electronic equipment and storage medium Active CN111782339B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010597813.9A CN111782339B (en) 2020-06-28 2020-06-28 Container creation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010597813.9A CN111782339B (en) 2020-06-28 2020-06-28 Container creation method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111782339A true CN111782339A (en) 2020-10-16
CN111782339B CN111782339B (en) 2024-04-12

Family

ID=72760690

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010597813.9A Active CN111782339B (en) 2020-06-28 2020-06-28 Container creation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111782339B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112379828A (en) * 2020-10-27 2021-02-19 华云数据控股集团有限公司 Container creation method and device based on dynamic file system
CN112799740A (en) * 2021-02-08 2021-05-14 联想(北京)有限公司 Control method and device and electronic equipment
CN112905537A (en) * 2021-02-20 2021-06-04 北京百度网讯科技有限公司 File processing method and device, electronic equipment and storage medium
CN113190325A (en) * 2021-04-09 2021-07-30 大唐微电子技术有限公司 Container creation method and device
CN113760325A (en) * 2021-05-11 2021-12-07 腾讯科技(深圳)有限公司 Container environment updating method and device
CN114064594A (en) * 2021-11-22 2022-02-18 马上消费金融股份有限公司 Data processing method and device
CN115202830A (en) * 2022-09-09 2022-10-18 统信软件技术有限公司 Root file system preparation method, system, computing device and readable storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105511943A (en) * 2015-12-03 2016-04-20 华为技术有限公司 Docker container running method and device
US20170083541A1 (en) * 2015-09-23 2017-03-23 International Business Machines Corporation Container Storage Migration
US20180365238A1 (en) * 2017-06-20 2018-12-20 Red Hat, Inc. Sharing Filesystems Between Containers
US20190004841A1 (en) * 2017-06-30 2019-01-03 Microsoft Technology Licensing, Llc Memory Sharing For Virtual Machines
CN110308972A (en) * 2019-07-05 2019-10-08 北京百度网讯科技有限公司 Method and apparatus for managing container mirror image
CN110659246A (en) * 2019-09-26 2020-01-07 北京百度网讯科技有限公司 Container-based file mounting method and device and electronic equipment
CN110955494A (en) * 2019-11-15 2020-04-03 北京浪潮数据技术有限公司 Virtual machine disk image construction method, device, equipment and medium
CN111221537A (en) * 2018-11-23 2020-06-02 中兴通讯股份有限公司 Cloud desktop upgrading method and device, cloud server and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170083541A1 (en) * 2015-09-23 2017-03-23 International Business Machines Corporation Container Storage Migration
CN105511943A (en) * 2015-12-03 2016-04-20 华为技术有限公司 Docker container running method and device
US20180365238A1 (en) * 2017-06-20 2018-12-20 Red Hat, Inc. Sharing Filesystems Between Containers
US20190004841A1 (en) * 2017-06-30 2019-01-03 Microsoft Technology Licensing, Llc Memory Sharing For Virtual Machines
CN111221537A (en) * 2018-11-23 2020-06-02 中兴通讯股份有限公司 Cloud desktop upgrading method and device, cloud server and storage medium
CN110308972A (en) * 2019-07-05 2019-10-08 北京百度网讯科技有限公司 Method and apparatus for managing container mirror image
CN110659246A (en) * 2019-09-26 2020-01-07 北京百度网讯科技有限公司 Container-based file mounting method and device and electronic equipment
CN110955494A (en) * 2019-11-15 2020-04-03 北京浪潮数据技术有限公司 Virtual machine disk image construction method, device, equipment and medium

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112379828A (en) * 2020-10-27 2021-02-19 华云数据控股集团有限公司 Container creation method and device based on dynamic file system
CN112379828B (en) * 2020-10-27 2024-03-19 华云数据控股集团有限公司 Container creation method and device based on dynamic file system
CN112799740A (en) * 2021-02-08 2021-05-14 联想(北京)有限公司 Control method and device and electronic equipment
CN112799740B (en) * 2021-02-08 2022-07-26 联想(北京)有限公司 Control method and device and electronic equipment
CN112905537A (en) * 2021-02-20 2021-06-04 北京百度网讯科技有限公司 File processing method and device, electronic equipment and storage medium
CN112905537B (en) * 2021-02-20 2022-09-02 北京百度网讯科技有限公司 File processing method and device, electronic equipment and storage medium
CN113190325A (en) * 2021-04-09 2021-07-30 大唐微电子技术有限公司 Container creation method and device
CN113760325A (en) * 2021-05-11 2021-12-07 腾讯科技(深圳)有限公司 Container environment updating method and device
CN113760325B (en) * 2021-05-11 2023-08-08 腾讯科技(深圳)有限公司 Container environment updating method and device
CN114064594A (en) * 2021-11-22 2022-02-18 马上消费金融股份有限公司 Data processing method and device
CN114064594B (en) * 2021-11-22 2023-09-22 马上消费金融股份有限公司 Data processing method and device
CN115202830A (en) * 2022-09-09 2022-10-18 统信软件技术有限公司 Root file system preparation method, system, computing device and readable storage medium

Also Published As

Publication number Publication date
CN111782339B (en) 2024-04-12

Similar Documents

Publication Publication Date Title
CN111782339B (en) Container creation method and device, electronic equipment and storage medium
US9652220B2 (en) Zero down-time deployment of new application versions
US9535754B1 (en) Dynamic provisioning of computing resources
CN106897095B (en) Method and device for hot repairing application program, readable storage medium and computing equipment
KR20200070085A (en) Method and apparatus for processing information
CN111427596B (en) Software upgrading method and device and terminal equipment
CN107368353B (en) Method and device for realizing hot addition of virtual machine memory
EP2778962B1 (en) Silo-aware databases
CN112580315A (en) Webpage table display method and device, terminal equipment and medium
US11113186B1 (en) Testing and publishing of resource handlers in a cloud environment
CN107291507B (en) Upgrading method for virtual hard disk of virtual machine and electronic equipment
US20130007377A1 (en) Message oriented middleware with integrated rules engine
CN112486552A (en) Server hot update method, device, equipment and storage medium
CN114356504A (en) Data migration method and device in cluster, electronic equipment and storage medium
CN110083366B (en) Application running environment generation method and device, computing equipment and storage medium
US11750451B2 (en) Batch manager for complex workflows
CN113835729A (en) Upgrading method and device, terminal equipment and computer readable storage medium
CN111324373A (en) Method and device for uploading multiple project files to code warehouse and computing equipment
CN116483470A (en) Method for acquiring configuration information, electronic equipment and medium
CN115714706A (en) Access acceleration system and method based on embedded H5, storage medium and electronic equipment
CN116049000A (en) Environment parameter configuration method, device, equipment, storage medium and product
US20220334820A1 (en) System and method for intermediate software upgrades for information handling systems
CN114880073A (en) Cloud application engine deployment method, device, equipment and storage medium for shielding Web framework for user
CN112328288A (en) Method, system, equipment and storage medium for updating server component
CN108363614B (en) Application service module management method and device and server

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
CB02 Change of applicant information

Address after: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Technology Holding Co.,Ltd.

Address before: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: Jingdong Digital Technology Holding Co.,Ltd.

Address after: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Digital Technology Holding Co.,Ltd.

Address before: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: JINGDONG DIGITAL TECHNOLOGY HOLDINGS Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant