CN111782339B - 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
CN111782339B
CN111782339B CN202010597813.9A CN202010597813A CN111782339B CN 111782339 B CN111782339 B CN 111782339B CN 202010597813 A CN202010597813 A CN 202010597813A CN 111782339 B CN111782339 B CN 111782339B
Authority
CN
China
Prior art keywords
virtual machine
file
directory
container
new
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010597813.9A
Other languages
Chinese (zh)
Other versions
CN111782339A (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.)
Jingdong Technology Holding Co Ltd
Original Assignee
Jingdong Technology Holding 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 Jingdong Technology Holding Co Ltd filed Critical Jingdong Technology Holding 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

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

Landscapes

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

Abstract

The application provides a container creation method, a 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 creation instruction, and acquiring a new agent file to be updated; and mounting the new agent file under a first virtual machine directory in the virtual machine, so that the virtual machine can acquire the new agent file according to the first virtual machine directory, and running a container based on the new agent file. By adopting the technical scheme provided by the application, the problem that the container in the running state cannot normally run 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 disclosure relates to the field of container technologies, and in particular, to a method and apparatus for creating a container, an electronic device, and a storage medium.
Background
The electronic device may have a container image file stored therein, and the electronic device may create a virtual machine and create a container in the virtual machine based on the container image file. In order to facilitate distinguishing between a virtual machine and an electronic device, the electronic device in 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, an electronic device may update a container image file and create a new container based on the updated container image file, thereby updating functions possessed by 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, that is, 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 changing the original container image file in the physical host into a new container image file.
However, for a container in an operating state in the updating 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 operate normally.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method, an apparatus, an electronic device, and a storage medium for creating a container, so as to solve a problem that a container in an operation state cannot operate normally when a new container is created based on an existing container image file updating method. The specific technical scheme is as follows:
in a first aspect, the present application provides a container creation method, where the method is applied to a physical host, and the physical host has a virtual machine deployed therein, and the method includes:
responding to a container creation instruction, and acquiring a new agent file to be updated;
and mounting the new agent file under a first virtual machine directory in the virtual machine, so that the virtual machine can acquire the new agent file according to the first virtual machine directory, and running a container based on the new agent file.
Optionally, the mounting the new proxy file to the first virtual machine directory in the virtual machine includes:
mounting the new agent file under a container resource directory corresponding to the virtual machine to obtain a host directory of the new agent file under the container resource directory;
mapping the host directory to a first virtual machine directory in the virtual machine.
Optionally, the mapping the host directory to a first virtual machine directory in the virtual machine includes:
the host directory is mapped under 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, the method being applied to a virtual machine deployed in a physical host, the method comprising:
responding to the physical host to mount a new agent file to be updated under a first virtual machine directory in the virtual machine, and acquiring the new agent file according to the first virtual machine directory;
and running the container based on the new agent side file.
Optionally, the running container based on the new proxy file includes:
mounting the new agent end 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;
executing the new proxy file to create a container.
Optionally, after the mounting the new proxy file to the root file system of the virtual machine to obtain the second virtual machine directory, the method further includes:
and unloading the first virtual machine directory.
In a third aspect, the present application further provides a container creation apparatus applied to a physical host having a virtual machine deployed therein, 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 under a first virtual machine directory in the virtual machine so that the virtual machine can acquire the new agent file according to the first virtual machine directory and run a container based on the new agent file.
Optionally, the mounting module includes:
the mounting sub-module is used for mounting the new agent file under the container resource directory corresponding to the virtual machine to obtain a host directory of the new agent file under the container resource directory;
and the mapping sub-module is used for mapping the host directory to a first virtual machine directory in the virtual machines.
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 sharing file system.
In a fourth aspect, the present application further provides 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 under 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 sub-module is used for mounting the new agent end 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 end file according to the second virtual machine directory;
and the execution sub-module is used for executing the new proxy 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 configured to implement any of the method steps of the first aspect, or any of the second aspect, when executing a program stored on a memory.
In a sixth aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements any of the first aspect, or any of the method steps of the second aspect.
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, above.
The beneficial effects of the embodiment of the application are that:
the embodiment of the application provides a container creation method, a device, electronic equipment and a storage medium, wherein a physical host can respond to a container creation instruction to acquire a proxy file to be updated, and then the physical host can mount a new proxy file under a first virtual machine directory in a virtual machine so that the virtual machine can acquire the new proxy file according to the first virtual machine directory and operate the container based on the new proxy file.
Because the update of the proxy-side file can be realized without replacing the container image file stored in the physical host, the virtual machine can normally transmit data with the physical host in the process of updating the container image file, and the container can normally operate.
Of course, not all of the above-described advantages need be achieved simultaneously in practicing any one of the products or methods 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 that are required to be used in the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a flow chart of a method for creating a container according to an embodiment of the present application;
FIG. 2 is a flow chart of another method of creating a container provided in an embodiment of the present application;
FIG. 3 is a flow chart of another method of creating a container provided in an embodiment of the present application;
FIG. 4 is a flow chart of another method of creating a container provided by an embodiment of the present application;
FIG. 5 is an exemplary diagram of a container creation method provided by an embodiment of the present application;
FIG. 6 is a schematic flow chart of updating a container image file according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a container creating device according to an embodiment of the present application;
FIG. 8 is a schematic view of another container creation apparatus according to an embodiment of the present disclosure;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
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 deployed. The physical host may have a container image stored therein, and the physical host may create a container in the virtual machine based on the container image.
In this embodiment of the present application, one virtual machine may be deployed in a physical host, or a plurality of virtual machines may be deployed in a 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 adopting 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.
The following will describe a detailed description of a method for creating a container provided in the embodiment of the present application with reference to the specific embodiment, as shown in fig. 1, and the specific steps are as follows:
and step 101, responding to a container creation instruction, and acquiring a new agent file to be updated.
In an implementation, when the container image file needs to be updated, a developer may store a new proxy file to be updated in the physical host, and then the developer may perform a preset action to enable the physical host to detect the container creation instruction. The preset action may be to input a command code representing updating the container image file, or click an update icon representing updating the container image file in a preset control page.
In response to the container creation instruction, the physical host may obtain the new proxy file to be updated in a variety of ways.
In one possible implementation, the new proxy file may be stored in the physical host, and the container creation instruction may carry a storage address of the new proxy file in the physical host, and the physical host may read the new proxy file according to the storage address. In another possible implementation manner, the new proxy file may be stored in a preset database, the container creation instruction may carry a file identifier of the new proxy file, and the physical host may obtain the new proxy file from the preset database according to the file identifier.
And 102, mounting the new agent file to a first virtual machine directory in the virtual machine.
In implementations, the physical host may determine a virtual machine to be subjected to a container image file update.
In this embodiment of the present application, when the number of virtual machines is 1, the virtual machines are the virtual machines to be updated with the container image files. When the number of virtual machines is plural, the physical host can determine the virtual machines to be subjected to the update of the container image file in various ways.
In one possible implementation, the container creation instruction may carry a target virtual machine identification, which is an identification of the virtual machine to be updated with the container image file. The physical host may determine a virtual machine to be updated with the container image file from among the deployed plurality of virtual machines according to the target virtual machine identification. In another possible implementation manner, the physical host may store a correspondence between the container and the virtual machine, and the physical host may determine, according to the correspondence, the virtual machine in which the container is deployed, and then, the physical host may use the determined virtual machine as the virtual machine to be updated with the container image file.
After determining the virtual machine that needs to update the container image file, the physical host may mount the new proxy file to the first virtual machine directory in the virtual machine for the determined virtual machine, where the specific mounting process will be described in detail later.
The virtual machine may then update the container image file based on the new proxy file, as will be described in more detail later.
In this embodiment of the present application, a physical host may respond to a container creation instruction to obtain a proxy file to be updated, and then, the physical host may mount the new proxy file under a first virtual machine directory in a virtual machine, so that the virtual machine obtains the new proxy file according to the first virtual machine directory, and runs the container based on the new proxy file.
Because the update of the proxy file can be realized without replacing the container image file stored in the physical host, the virtual machine can normally transmit data with the physical host in the update process of the proxy file, and the container can normally run.
Optionally, for each virtual machine, a container resource directory corresponding to the virtual machine may be stored in the physical host. The container resource directory may be loaded with files required for the virtual machine to start the container or a directory of the required files, where the files required for starting the container are as follows: rootfs (root file system) of the container.
The physical host may mount the new proxy file under the first virtual machine directory of the virtual machine based on the container resource directory corresponding to the virtual machine, as shown in fig. 2, and the specific processing procedure includes:
step 201, mounting the new agent file under the container resource directory corresponding to the virtual machine, and obtaining a host directory of the new agent file under the container resource directory.
In implementation, the physical host may mount the new proxy file under the container resource directory corresponding to the virtual machine, to obtain a directory of the new proxy file under the container resource directory, that is, a host directory of the new proxy file in the physical host.
For example, the new agent file to be updated is a kata-agent, the identifier of the virtual machine to be updated with the container image file is de0eb57efdbe, and the container resource directory corresponding to the virtual machine in the physical host is/run/kata-containers/shared/sadbox/de 0eb57efdbe.
The physical host can mount the new agent file kata-agent to the corresponding container resource catalog/run/kata-containers/shared/sadbox/de 0eb57efdbe of the virtual machine to obtain the catalog of the new agent file under the container resource catalog, namely, the host catalog is: a/run/kata-containers/shared/sadbox/de 0eb57efdbe/kata-agent.
Step 202, mapping the host directory to a first virtual machine directory in the virtual machine.
In implementations, the physical host may map a host directory under a first virtual machine directory in the virtual machine. Thus, 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 by which the virtual machine obtains the new proxy file based on the first virtual machine directory will be described in detail later.
Alternatively, the physical host may map the host directory to any non-system directory in the virtual machine, e.g., 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.
Alternatively, the physical host may map the host directory to a preset directory in the virtual machine, for example, the preset directory/run/kata-containers/shared/containers are stored in the virtual machine, and resource files required for starting the container are all mounted in the preset directory. The physical host may map the host directory to the preset directory, i.e., the first virtual machine directory is/run/kata-containers/shared/containers.
In this embodiment of the present application, the physical host may mount the new proxy file under the container resource directory corresponding to the virtual machine, to obtain a host directory, and then map the host directory under the first virtual machine directory in the virtual machine. Because the new agent file is mounted under 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 transmit the new agent file to the virtual machine.
Optionally, the embodiment of the present application further provides an implementation manner of mapping a host directory to a first virtual machine directory in a virtual machine by a physical host, including: the host directory is mapped under a first virtual machine directory in the virtual machines based on the directory sharing file system. The directory sharing file system may be 9pfs (plan 9file system), or virtio-fs.
Because the host directory is mapped under the first virtual machine directory in the virtual machines based on the directory sharing system, the virtual machines can access the new proxy files mounted under the host directory by accessing the first virtual machine directory, thereby realizing data sharing between the physical hosts and the virtual machines.
Alternatively, the physical host may also select other manners to share data with the virtual machine, for example, the physical host may mount the container image file stored in the physical host into the virtual machine as a block device mounted on the virtual machine based on nvidmm characteristics of the kernel.
Based on the same technical concept, the embodiment of the application also provides a container creation method, which can be applied to virtual machines deployed in physical hosts.
The following will describe a detailed description of a method for creating a container provided in the embodiment of the present application with reference to the specific embodiment, as shown in fig. 3, and the specific steps are as follows:
step 301, in response to the physical host mounting the new proxy file to be updated under a first virtual machine directory in the virtual machine, acquiring the new proxy file according to the first virtual machine directory.
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 the new proxy file in response to the container creation instruction, and mount the new proxy file under the first virtual machine directory in the virtual machine, and the specific processing procedure may refer to the processing procedures of the steps 101 to 102, which are not described herein.
After the physical host mounts the new agent file under the first virtual machine directory, the virtual machine can acquire the first virtual machine directory, and then the virtual machine can acquire the new agent file to be updated from the physical host according to the first virtual machine directory.
Optionally, the virtual machine may acquire the first virtual machine directory in a plurality of manners, and in a feasible implementation manner, the first virtual machine directory is a preset directory in the virtual machine, and the virtual machine may acquire the first virtual machine directory that is locally pre-stored. 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, running the container based on the new agent side file.
In an implementation, the manner in which the virtual machine runs the container based on the new agent file may be varied, and in a possible implementation, the virtual machine may mount the new agent file into the 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 can directly execute the new agent file acquired according to the first virtual machine directory, thereby realizing the creation and management of the container.
In the embodiment of the application, in response to the fact that the physical host mounts the new agent file to be updated under a first virtual machine directory in the virtual machine, the virtual machine can acquire the new agent file according to the first virtual machine directory, and then the virtual machine can operate the container based on the new agent file. The update of the proxy file can be realized without changing the container image file stored in the physical host, so that the virtual machine can normally transmit data with the electronic equipment in the update process of the proxy file, and the container can normally operate.
Optionally, the embodiment of the present application further provides an implementation manner of creating a container based on the new proxy file, as shown in fig. 4, including the following steps:
and 401, mounting the new agent end file into a root file system of the virtual machine to obtain a second virtual machine directory.
In implementation, the virtual machine may mount the new proxy file into a root file system of the virtual machine to obtain the second virtual machine directory.
For example, the virtual machine may mount the new agent file kata-agent into 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 proxy 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 will not be repeated here.
In the embodiment of the application, the virtual machine may mount the new proxy file to a root file system of the virtual machine to obtain the second virtual machine directory. The virtual machine may then obtain the new proxy file from the second virtual machine directory, after which the virtual machine may execute the new proxy file to create a container. Thus, the creation of a container based on the updated new proxy file can be realized.
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 uninstall the first virtual machine directory/run/kata-containers/shared/containers/.
In the embodiment of the application, the virtual machine mounts the new proxy file into the root file system of the virtual machine and uninstalls the first virtual machine directory, so that the problem that the new proxy file cannot be accessed due to repeated mounting of the new proxy file can be avoided, and the updating stability of the new proxy file is improved.
Optionally, an exemplary diagram of updating a container image file provided in an embodiment of the present application, as shown in fig. 5, includes the following steps:
in step 501, the physical host responds to a container creation instruction to acquire a new proxy file to be updated.
In implementation, the processing of this step may refer to the processing of step 101, which is not described herein.
Step 502, the physical host mounts the new agent file under the container resource directory corresponding to the virtual machine, and obtains a host directory of the new agent file under the container resource directory.
In implementation, the processing procedure of this step may refer to the processing procedure of step 201, which is not described herein.
In 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.
And 504, the virtual machine acquires a new agent file according to the first virtual machine directory.
In implementation, the processing of this step may refer to the processing of step 301, which is not described herein.
And 505, the virtual machine mounts the new agent end file into a root file system of the virtual machine to obtain a second virtual machine directory.
In implementation, the processing of this step may refer to the processing of step 401, which is not described herein.
And step 506, the virtual machine acquires the new agent file according to the second virtual machine directory.
In step 507, the virtual machine executes the new proxy file to create a container.
Optionally, as shown in fig. 6, a flow chart of updating a container image file is provided in an embodiment of the present application, where 610 represents a physical host, 620 represents a virtual machine, kata-containers, img represents a container image file stored in the physical host, kata-run represents an application program for performing container management, and kata-agent represents a new agent file.
Physical host 610, when configuring virtual machine 620, may mount container image files kata-containers.img into virtual machine 620 based on the nvidmm characteristics of the kernel, as a block device that is mounted to virtual machine 620, which may be denoted as/dev/pmem 0p1. 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 rootfs (root file system) of the virtual machine. That is, the directory of the container image file kata-containers, img is used as the root directory of the virtual machine 620, and the program script included in the container image file kata-containers, img is executed in the virtual machine 620 according to the root directory.
If the container image file needs to be updated, the physical host 610 may mount the new agent file kata-agent to be updated under the container resource directory/run/kata-containers/shared/sendboxes/$sid corresponding to the virtual machine in a bind mount manner to obtain a host directory/run/kata-containers/shared/sendboxes/$sild/kata-agent. Then, the physical host 610 may map the host directory to the first virtual machine directory/run/kata-containers/shared/containers in the virtual machine vm through the directory sharing file system 9 pfs.
During the running process of the virtual machine, the kernel starts a system md process, and the system md process may execute step S1 to pull up the reinitiate process. The preinit process may execute step S2 to access a new agent file kata-agent under the first virtual machine directory/run/kata-containers/shared/containers. Then, the preinit process may perform step S3 to copy the new agent file kata-agent under the second virtual machine directory/usr/bin. Thereafter, the system md process may run the kata-agent program by executing the kata-agent file, and the physical host 610 may perform step S4 to command the kata-agent program for container creation through the kata-run, grpc api. The kata-agent program may perform step S5 to create a container in the virtual machine 620.
Optionally, the 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 when configuring the virtual machine to obtain a decompressed catalog. 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 convenience of distinction, the proxy file contained in the container image file is referred to as an original proxy file, and the proxy file to be updated is referred to as a new proxy file.
Subsequently, when the container image file is updated, the physical host may map the new proxy file into the virtual machine based on the directory shared file system. Then, the virtual machine can replace the original proxy file in the decompressed directory with a new proxy file.
Based on the same technical concept, the present application also provides a container creation apparatus applied to a physical host having a virtual machine deployed therein, as shown in fig. 7, the apparatus comprising:
an obtaining module 710, configured to obtain a new proxy file to be updated in response to the container creation instruction;
and the mounting module 720 is configured to mount the new proxy file under a first virtual machine directory in the virtual machine, so that the virtual machine obtains the new proxy file according to the first virtual machine directory, and runs a container based on the new proxy file.
Optionally, the mounting module includes:
the mounting sub-module is used for mounting the new agent file under the container resource directory corresponding to the virtual machine to obtain a host directory of the new agent file under the container resource directory;
and the mapping sub-module is used for mapping the host directory to a first virtual machine directory in the virtual machines.
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 sharing file system.
In this embodiment of the present application, a physical host may respond to a container creation instruction to obtain a proxy file to be updated, and then, the physical host may mount the new proxy file under a first virtual machine directory in a virtual machine, so that the virtual machine obtains the new proxy file according to the first virtual machine directory, and runs the container based on the new proxy file.
Because the update of the proxy-side file can be realized without replacing the container image file stored in the physical host, the virtual machine can normally transmit data with the physical host in the process of updating the container image file, and the container can normally operate.
Based on the same technical concept, the present application also provides a container creation apparatus applied to a virtual machine deployed in a physical host, as shown in fig. 8, the apparatus comprising:
an obtaining module 810, configured to obtain, in response to the physical host mounting a new proxy file to be updated under a first virtual machine directory in the virtual machine, the new proxy file according to the first virtual machine directory;
and the operation module 820 is used for operating the container based on the new agent file.
Optionally, the operation module includes:
the mounting sub-module is used for mounting the new agent end 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 end file according to the second virtual machine directory;
and the execution sub-module is used for executing the new proxy 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 the embodiment of the application, in response to the fact that the physical host mounts the new agent file to be updated under a first virtual machine directory in the virtual machine, the virtual machine can acquire the new agent file according to the first virtual machine directory, and then the virtual machine can operate the container based on the new agent file. The update of the proxy file can be realized without changing the container image file stored in the physical host, so that the virtual machine can normally transmit data with the electronic equipment in the update process of the proxy file, and the container can normally operate.
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 perform communication with each other through the communication bus 904,
a memory 903 for storing a computer program;
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 above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include 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 aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment provided herein, there is also 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 container creation methods described above.
In yet another embodiment provided herein, there is also provided a computer program product containing instructions that, when run on a computer, cause the computer to perform any of the container creation methods of the above embodiments.
In the above embodiments, it may be implemented in whole or in part 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, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more 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)), etc.
It should be noted that in this document, relational terms such as "first" and "second" and the like are 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. Moreover, 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 one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing is merely a specific embodiment of the application to enable one skilled in the art to understand or practice the 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 (9)

1. A container creation method, the method being applied to a physical host having a virtual machine deployed therein, the method comprising:
responding to a container creation instruction, and acquiring a new proxy file to be updated, wherein the new proxy file is used for updating a container mirror file;
the new agent end file is mounted under a first virtual machine directory in the virtual machine, so that the virtual machine can acquire the new agent end file according to the first virtual machine directory and operate a container based on the new agent end file, and the virtual machine comprises: mounting the new agent end 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; executing the new proxy file to create a container.
2. The method of claim 1, wherein the mounting the new proxy file under a first virtual machine directory in the virtual machine comprises:
mounting the new agent file under a container resource directory corresponding to the virtual machine to obtain a host directory of the new agent file under the container resource directory;
mapping the host directory to a first virtual machine directory in the virtual machine.
3. The method of claim 2, wherein mapping the host directory to a first one of the virtual machines comprises:
the host directory is mapped under a first one of the virtual machines based on a directory sharing file system.
4. A container creation method, wherein the method is applied to a virtual machine deployed in a physical host, the method comprising:
responding to the physical host to mount a new agent file to be updated under a first virtual machine directory in the virtual machine, and acquiring the new agent file according to the first virtual machine directory, wherein the new agent file is used for updating a container mirror file;
running a container based on the new agent side file, including: mounting the new agent end 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; executing the new proxy file to create a container.
5. The method of claim 4, wherein after the new proxy file is mounted to the root file system of the virtual machine to obtain the second virtual machine directory, further comprising:
and unloading the first virtual machine directory.
6. A container creation apparatus, the apparatus being applied to a physical host having a virtual machine deployed therein, the apparatus comprising:
the device comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for responding to a container creation instruction and acquiring a new proxy file to be updated, and the new proxy file is used for updating a container mirror file;
the mounting module is used for mounting the new agent file under a first virtual machine directory in the virtual machine, so that the virtual machine can acquire the new agent file according to the first virtual machine directory and run a container based on the new agent file, and the virtual machine comprises: mounting the new agent end 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; executing the new proxy file to create a container.
7. A container creation apparatus, the apparatus being 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 under a first virtual machine directory in the virtual machine, and acquiring the new agent file according to the first virtual machine directory, wherein the new agent file is used for updating a container mirror file;
the operation module is used for operating the container based on the new agent end file and comprises the following steps: mounting the new agent end 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; executing the new proxy file to create a container.
8. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-3, or claims 4-5, when executing a program stored on a memory.
9. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-3, or claims 4-5.
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 CN111782339A (en) 2020-10-16
CN111782339B true 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)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112379828B (en) * 2020-10-27 2024-03-19 华云数据控股集团有限公司 Container creation method and device based on dynamic file system
CN112799740B (en) * 2021-02-08 2022-07-26 联想(北京)有限公司 Control method and device and electronic equipment
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
CN113760325B (en) * 2021-05-11 2023-08-08 腾讯科技(深圳)有限公司 Container environment updating method and device
CN114064594B (en) * 2021-11-22 2023-09-22 马上消费金融股份有限公司 Data processing method and device
CN115202830B (en) * 2022-09-09 2022-12-30 统信软件技术有限公司 Root file system preparation method, system, computing device and readable storage medium

Citations (5)

* 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
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

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9852137B2 (en) * 2015-09-23 2017-12-26 International Business Machines Corporation Container storage migration
US10909165B2 (en) * 2017-06-20 2021-02-02 Red Hat, Inc. Sharing filesystems between containers
US20190004841A1 (en) * 2017-06-30 2019-01-03 Microsoft Technology Licensing, Llc Memory Sharing For Virtual Machines

Patent Citations (5)

* 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
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

Also Published As

Publication number Publication date
CN111782339A (en) 2020-10-16

Similar Documents

Publication Publication Date Title
CN111782339B (en) Container creation method and device, electronic equipment and storage medium
US10002054B2 (en) Method and system for performing automatic system recovery
EP3800538A1 (en) Method and apparatus for data migration
CN110908753B (en) Intelligent fusion cloud desktop server, client and system
CN113849272A (en) Method and device for adding GPU (graphics processing Unit) resources in virtual machine
EP2778962A1 (en) Silo-aware databases
CN107291507B (en) Upgrading method for virtual hard disk of virtual machine and electronic equipment
CN116483514A (en) Container starting method and device, electronic equipment and storage medium
CN110083366B (en) Application running environment generation method and device, computing equipment and storage medium
CN110471744B (en) Password modification method, device, equipment and computer readable storage medium
CN113282342A (en) Deployment method, device, system, electronic equipment and readable storage medium
US10997269B1 (en) Using web application components with different web application frameworks in a web application
CN111324373A (en) Method and device for uploading multiple project files to code warehouse and computing equipment
CN111124545A (en) Application program starting method and device, electronic equipment and storage 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
CN115794690A (en) Processing method and device based on external equipment in server
CN113126982B (en) Application program generation and operation method and device
US20220334820A1 (en) System and method for intermediate software upgrades for information handling systems
CN112328288A (en) Method, system, equipment and storage medium for updating server component
CN114564210A (en) Copy deployment method, device, system, electronic equipment and storage medium
CN111736973A (en) Service starting method, device, server and storage medium
CN108363614B (en) Application service module management method and device and server
US20210389957A1 (en) Managing boot device orders for computing devices
US20090292735A1 (en) Decluttering a computing system

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