Container management method and apparatus, device, and medium
By adding a shared file directory and modifying files in the read-only layer of the container's root file system, the problems of time-consuming container creation and unmodifiable shared files are solved, achieving efficient file management and security.
Patent Information
- Application Number
- PCT/CN2024/107838
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-18
- Filing Date
- 2024-07-26
- Publication Date
- 2025-09-25
AI Technical Summary
In the prior art, during the container creation process, the storage method of shared files causes the container creation to take a long time, and the shared files cannot be modified without affecting other containers.
A shared file directory is added to the read-only layer of the target container's root file system, and modification requests for the shared file directory are received. Files are downloaded from the shared file system to the read-write layer for modification without affecting the original files in the read-only layer.
This avoids time-consuming file downloads when starting a container, allows shared files to be modified without affecting other containers, and improves the security and management efficiency of files between containers.
Smart Images

Figure CN2024107838_25092025_PF_FP_ABST
Abstract
Description
Container management method, device, equipment and medium
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on March 18, 2024, with application number 202410310073.4 and invention name “A container management method, device, equipment and medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present disclosure relates to the field of cloud computing technology, and in particular to a container management method, apparatus, device, and medium. Background Art
[0003] With the development of cloud computing technology, container orchestration systems are becoming increasingly widespread. When creating a container within a container orchestration system, shared files can be stored in the container's file system. This storage is typically achieved through network downloads, image downloads, file system mounts, and other methods. However, these methods all have drawbacks: container creation takes a long time, and shared files cannot be modified without affecting other containers.
[0004] Summary of the Invention
[0005] In order to solve the above technical problems, the present disclosure provides a container management method, apparatus, device and medium.
[0006] An embodiment of the present disclosure provides a container management method, the method comprising:
[0007] During the creation of the target container, a shared file directory is added to the read-only layer of the root file system of the target container, wherein the shared file directory is a mount directory of the shared file system;
[0008] receiving a modification request for a first file in the shared file directory of the target container;
[0009] The first file is downloaded from the shared file system to the shared file directory, and copied from the shared file directory to the read-write layer, and the first file is modified in the read-write layer.
[0010] The present disclosure also provides a container management device, the device comprising:
[0011] A directory adding module, configured to add a shared file directory to the read-only layer of the root file system of the target container during the creation of the target container, wherein the shared file directory is a mount directory of the shared file system;
[0012] a first request receiving module, configured to receive a request to modify a first file in the shared file directory of the target container;
[0013] The file modification module is used to download the first file from the shared file system to the shared file directory, copy the first file from the shared file directory to the read-write layer, and perform modification operations on the first file in the read-write layer.
[0014] An embodiment of the present disclosure further provides an electronic device, comprising: a processor; a memory for storing instructions executable by the processor; and the processor for reading the executable instructions from the memory and executing the instructions to implement the container management method provided in the embodiment of the present disclosure.
[0015] An embodiment of the present disclosure further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is used to execute the container management method provided by the embodiment of the present disclosure.
[0016] The embodiments of the present disclosure further provide a computer program product, including a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, the steps of the container management method provided in the embodiments of the present disclosure are implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0018] FIG1 is a flow chart of a container management method provided by an embodiment of the present disclosure;
[0019] FIG2 is a schematic diagram of a root file system provided by an embodiment of the present disclosure;
[0020] FIG3 is a flow chart of another container management method provided by an embodiment of the present disclosure;
[0021] FIG4 is a schematic diagram of obtaining a snapshot plug-in tag according to an embodiment of the present disclosure;
[0022] FIG5 is a schematic structural diagram of a container management device provided by an embodiment of the present disclosure;
[0023] FIG6 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0025] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0026] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0027] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0028] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0029] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0030] With the development of cloud computing technology, container orchestration systems are becoming more and more widely used. When creating a container in a container orchestration system, shared files can exist in the container's file system.
[0031] In related technologies, shared files can be stored on the network. Before the container actually executes the startup command, it downloads the shared file from the network using a Uniform Resource Locator (URL) and stores the shared file in a designated location within the container. However, if the shared file is large, the time required to start the container increases significantly, and the larger the shared file, the longer it takes.
[0032] Alternatively, through container image technology, the image corresponding to the shared file is added to the original image of the container to obtain a new image. When the container starts, the new image is downloaded and the container is created using the new image, which requires the additional download of the image corresponding to the shared file. The larger the shared file, the larger the image corresponding to the shared file, and the larger the image downloaded when the container starts. The time taken to start the container increases significantly, and the larger the shared file, the more time it takes. In addition, when shared files change frequently, new images need to be built frequently, which will cause excessive storage pressure on the image repository and node images, making image maintenance more difficult.
[0033] Alternatively, you can store shared files in a distributed file system and, when creating a container, mount the distributed file system to the container, thereby enabling shared files in the distributed file system to be shared. In the case of a read-only mount, processes in the container do not have permission to modify the shared files. In the case of a writable mount, processes in one container can modify the shared files, but this will affect the use of the shared files by other containers.
[0034] The above methods all have the drawbacks of taking a long time to create a container and being unable to modify shared files without affecting other containers.
[0035] In order to solve the above problems, the embodiments of the present disclosure provide a container management method, which is introduced below in conjunction with specific embodiments.
[0036] Figure 1 is a flow chart of a container management method provided by an embodiment of the present disclosure. The method can be executed by a container management device, wherein the device can be implemented using software and / or hardware and can generally be integrated into an electronic device. As shown in Figure 1, the method includes:
[0037] Step 101: During the creation of a target container, a shared file directory is added to the read-only layer of the root file system of the target container, wherein the shared file directory is a mount directory of the shared file system.
[0038] The target container can be the container currently being created or started in the container orchestration system, any container in a container group, or the container currently being created or started in the container runtime. This embodiment does not restrict the type of the target container. For example, the target container can be a standard container that meets a certain container interface specification, regardless of the specific container interface specification.
[0039] The container orchestration system can be used to manage containerized applications on multiple hosts in a cloud platform. The container orchestration system can be used to automatically deploy, scale, and manage containerized applications. The container orchestration system is also called a container orchestration engine. The container group in the container orchestration system can be the smallest unit created or deployed by the container orchestration system. A container group encapsulates one or more containers. The container runtime is an industrial-grade standard container runtime. The container runtime can implement one or more of the following functions: managing the life cycle of the container, pulling or pushing container images, managing the storage of images and container data, calling command-line tools to run containers, and managing container networks and network interfaces. This embodiment does not limit the application scenarios of the container management method. For example, the application scenario may include one of the following: cloud compilation cache for large projects, dependency management of development environments in cloud development environments, and creation of container environments.
[0040] The root file system (RootFS) can be a file system used to provide an isolated execution environment for container processes. This root file system can be mounted on the root directory of the container. The root file system can include a read-only layer (LowerDir) and a read-write layer (UpperDir). The read-only layer can be a layer with read-only but non-writable access rights. This read-only layer can record portions of the operating system in incremental increments. This embodiment does not limit the number of read-only layers; for example, there can be multiple read-only layers. The read-write layer can be a layer with read-write access rights. This read-write layer can be located above the read-only layer and can record one or more of the creation, modification, and deletion of files in the root file system. This embodiment does not limit the number of read-write layers; for example, there can be one read-write layer. When reading a file, the file is first read from the read-write layer. If the file exists in the read-write layer, it indicates that the file has been modified, and the read-only layer is no longer read. If the file does not exist in the read-write layer, the file is read from the read-only layer.
[0041] The shared file directory can be a new directory in the read-only layer of the target container's root file system, which can be mounted on a shared file system. A shared file system can be used to implement file sharing between multiple containers in a container orchestration system. The shared file system can include multiple shared files, each of which can be accessed by multiple containers.
[0042] In the embodiment of the present disclosure, the container management method may be executed by a container orchestration system or a container runtime, that is, the container management device may be provided in the container orchestration system or the container runtime.
[0043] In an embodiment of the present disclosure, when creating a target container, a root file system is first constructed based on the image corresponding to the target container. Specifically, FIG2 is a schematic diagram of a root file system provided by an embodiment of the present disclosure. As shown in FIG2 , the container management device can download an image from a pre-set image repository. The image includes multiple compressed files, each of which corresponds to a layer in the read-only layer. The compressed files are decompressed into a directory of the corresponding layer, and the shared file system is mounted in a read-only manner to the shared file directory to obtain the read-only layer of the root file system. The read-write layer of the root file system is set to an empty directory to obtain the root file system.
[0044] FIG3 is a flow chart of another container management method provided by an embodiment of the present disclosure. As shown in FIG3 , in some embodiments of the present disclosure, during the creation of a target container, a shared file directory is added to the read-only layer of the root file system of the target container, including:
[0045] Step 301: During the creation of the target container, a snapshot plug-in tag is obtained, where the snapshot plug-in tag includes a mount directory of a shared file system.
[0046] Snapshot plugin labels can be labels defined and readable by the container runtime snapshot plugin (Snapshotter Plugin) in the container orchestration system. A snapshot plugin can be a plugin used to manage snapshots, such as creating and deleting them. Labels can be key-value pairs used to identify resources in the container orchestration system.
[0047] In an embodiment of the present disclosure, during the creation process of the target container, the container management apparatus may obtain a snapshot plug-in tag including a mount directory of a shared file system.
[0048] In some embodiments of the present disclosure, obtaining a snapshot plug-in label includes: obtaining a target annotation including a volume number of a shared file system, determining that the mount directory of the volume number is a mount directory of the shared file system; and calling a container runtime interface service to convert the target annotation into a snapshot plug-in label including a mount directory of the shared file system.
[0049] Among them, the volume number can be the name of the volume in the shared file system. The target annotation can be an additional field added to the annotation of the target container for the shared file system, and the specific value of the target annotation can be the volume number corresponding to the shared file system. Annotations can be used to attach non-identifying metadata to resource objects in the container orchestration system. The container runtime interface service can be a service implemented by a standardized plug-in interface, which is used to connect the container runtime and the container orchestration system, so that the container orchestration system can interact with different container runtimes.
[0050] In this embodiment, when a user creates a container group with a shared file directory, the user can add a target annotation in the annotation field of the container group declaration. The value of the target annotation is the volume number corresponding to the shared file system, so that the volume number of the shared file system is recorded through the target annotation.
[0051] Furthermore, the container control device schedules the container group to a node (Node) through the container orchestration system, and mounts the volume corresponding to the volume number to the directory of the node on this node. In the code for creating a container of the container runtime interface service, a configuration code for converting the annotation of the container group of the container orchestration system into a snapshot plug-in label is added. Furthermore, in the process of creating a target container, the container control device calls the container runtime interface service of the container runtime through the container runtime interface protocol, and converts the target annotation into the snapshot plug-in label agreed upon by the target snapshot plug-in of the container runtime through the container runtime service interface. The value of the snapshot plug-in label is the directory of the node corresponding to the volume corresponding to the target annotation, that is, the value of the snapshot plug-in label is the mount directory of the shared file system.
[0052] In the above solution, snapshot plug-in labels are obtained based on the container orchestration system.
[0053] In some embodiments of the present disclosure, obtaining the snapshot plug-in tag includes: obtaining the snapshot plug-in tag by remotely calling a service.
[0054] Among them, remote call service, also known as remote procedure call service, is a technology used to achieve communication and interaction between different processes or services.
[0055] In some embodiments of the present disclosure, a user invokes a remote call service during the container runtime to enable a container control device to obtain a snapshot plug-in label. Specifically, the user manually creates an empty directory and sets the empty directory as a mount directory for a shared file system. Based on the definition of the snapshot plug-in, a snapshot plug-in label including the mount directory for the shared file system is constructed. The user then sends the snapshot plug-in label to the container control device through the remote call service during the container runtime, and the container control device then obtains the snapshot plug-in label.
[0056] In the above solution, snapshot plug-in labels are obtained based on the container runtime.
[0057] Figure 4 is a schematic diagram of obtaining a snapshot plug-in label according to an embodiment of the present disclosure. As shown in Figure 4, a user can obtain a target annotation through the container orchestration system, call the container runtime service interface to convert the target annotation into a snapshot plug-in label, and then process the snapshot plug-in label through the target snapshot plug-in. Alternatively, a user can obtain a snapshot plug-in label through a remote call service at the container runtime, and then process the snapshot plug-in label through the target snapshot plug-in.
[0058] Step 302: Call the target snapshot plug-in and add a mount directory of the shared file system as a shared file directory in the read-only layer of the root file system of the target container based on the snapshot plug-in label.
[0059] Among them, the target snapshot plug-in can be a snapshot plug-in re-implemented in the container runtime. The implementation code of the target snapshot plug-in has been modified. When a snapshot plug-in tag is found, the mount directory of the shared file system in the snapshot plug-in tag can be added to the read-only layer of the root file system.
[0060] In this embodiment, the container management device can call the target snapshot plug-in. The target snapshot plug-in extracts the value of the snapshot plug-in label to obtain the mount directory of the shared file system. The shared file system's mount directory is added to the read-only layer option of the write-time multiplexing file system's mount parameter, and the mount parameter is returned to the container runtime. The container runtime calls the mount system based on the mount parameter returned by the target snapshot plug-in to construct a root file system. This root file system contains the contents of the volume corresponding to the shared file system.
[0061] In the above solution, a shared file directory is added to the read-only layer of the root file system based on the snapshot plug-in label, creating a foundation for subsequent personalized file modifications for the container.
[0062] Step 102: Receive a modification request for a first file in a shared file directory of a target container.
[0063] The first file may be a file to be modified and not modified that is recorded in the shared file directory. This embodiment does not limit the number and type of the first file. The modification request may be a request to modify the first file.
[0064] In this embodiment, if the user needs to modify the first file in the shared file directory, the target container can create a corresponding file modification process, and send a modification request for the first file to the container management device through the file modification process, and the container management device receives the modification request for the first file.
[0065] Step 103: Download the first file from the shared file system to a shared file directory, copy the first file from the shared file directory to the read-write layer, and modify the first file in the read-write layer.
[0066] The modification operation may be an operation of modifying the first file, and the modification operation may include one or more of adding file content, deleting file content, and updating file content.
[0067] In the embodiment of the present disclosure, based on the copy-on-write feature of the copy-on-write file system, the first file is recorded in the shared file directory in the form of a directory, but the specific data of the first file is not stored in the shared file directory. After receiving the modification request for the first file, the container management device can download the first file from the shared file system to the shared file directory of the read-only layer of the root file system, and copy the shared file directory to the read-write layer of the root file system, and perform modification operations on the first file in the read-write layer. Therefore, the modification of the copied first file in the read-write layer will not modify the original first file stored in the shared file system, thereby ensuring that the original first file will not be tampered with by a container.
[0068] The container management solution provided by the embodiment of the present disclosure includes the following steps: during the creation of a target container, a shared file directory is added to the read-only layer of the root file system of the target container, wherein the shared file directory is a mounted directory of the shared file system; a modification request for a first file in the shared file directory of the target container is received; the first file is downloaded from the shared file system to the shared file directory, and the shared file directory is copied to the read-write layer, and the first file is modified in the read-write layer. By adopting the above technical solution, a mounted directory of the shared file system is added to the read-only layer of the root file system of the target container, and the file sharing in the shared file system is realized by mounting, thereby avoiding the excessive time spent on downloading the shared file when the container is started. Subsequently, when a modification request for the first file is received, the first file is downloaded from the shared file system to the shared file directory of the target container and copied to the read-write layer, and the modification operation of the first file is realized in the read-write layer. The first file copied in the read-write layer is modified instead of the original first file in the shared file system mounted on the read-only layer. This not only realizes the modification of the shared file, but also makes the modification invisible to other containers.
[0069] Furthermore, modifications to the copied first file in the read-write layer by the target container do not affect the original first file in the shared file system, thus preventing any impact on other containers' use of the original first file and improving the security of file sharing between containers. Furthermore, the shared file system enables unified management of shared files between containers, reducing file management costs.
[0070] In some embodiments of the present disclosure, the container management method also includes: adding configuration code of the snapshot plug-in label in the code of the target snapshot plug-in, wherein the configuration code of the snapshot plug-in label is used to add the value of the snapshot plug-in label to the options of the read-only layer of the write-time copy file system corresponding to the root file system, and the root file system is constructed based on the write-time copy file system.
[0071] The configuration code for the snapshot plugin tag can be a functional code for configuring the snapshot plugin tag. The copy-on-write file system can be a default file system for a container. In this copy-on-write file system, when a file is modified, it is necessary to copy the file from the read-only layer to the read-write layer and modify the copied file in the read-write layer without modifying the original file in the read-only layer. Options can be parameters in the mount array (mounts[0]) returned by the write-reuse file system.
[0072] In this embodiment, during the root file system construction phase of creating the target container, the container runtime can call the configuration declaration target snapshot plugin. If the target snapshot plugin finds the value of the snapshot plugin tag, it will add the snapshot plugin tag value to the front of the read-only layer option in the mount array returned by the copy-on-write file system.
[0073] For example, if the value of the snapshot plugin tag is: / mount / nas, and the options for the read-only layer in the mount array are: mounts[0].Options["lowerdir"] = " / lower1:lower2:lower3", then the options for the read-only layer of the copy-on-write file system after adding the value of the snapshot plugin tag are: mounts[0].Options["lowerdir"] = " / mount / nas: / lower1:lower2:lower3".
[0074] In the above solution, the mount directory of the shared file system recorded by the value of the snapshot plug-in label is added to the options of the read-only layer of the write-time copy file system through configuration code, thereby adding the shared file directory corresponding to the shared file system to the read-only layer of the root file system of the target container.
[0075] In some embodiments of the present disclosure, the container management method further includes: configuring and using a target snapshot plug-in in the container runtime and the container orchestration system.
[0076] In this embodiment, since the container runtime uses a plug-in mechanism, the target snapshot plug-in must be registered with the container runtime for it to function properly. Specifically, the configuration code is compiled to enable the target snapshot plug-in. The container runtime configuration file configures the target snapshot plug-in for use. Furthermore, the container runtime is restarted. Optionally, the container runtime configuration file may include a listener for the target snapshot plug-in address.
[0077] Since there are multiple snapshot plug-ins in the container orchestration system, if the snapshot plug-in is not configured in the container orchestration system, the default (i.e., native) snapshot plug-in will be used. In order to use the target snapshot plug-in in the container orchestration system, it is necessary to configure the target snapshot plug-in in the container orchestration system. Specifically, the user can modify the configuration file in advance and declare the use of the target snapshot plug-in. Since by default, the interface will not pass the snapshot plug-in label to the container's snapshot plug-in, however, in this embodiment, the changes to the read-only layer rely on the snapshot plug-in label to implement configuration transfer. In addition, in the container orchestration system, special data is generally transferred through annotations or labels of the container group.
[0078] Therefore, to transparently pass snapshot plugin tags to the container orchestration system, it's necessary to define annotations for the container group or define the tag key and its semantics. Furthermore, the interface service's container creation logic needs to be modified, and the source code needs to be implemented to convert the container orchestration system's container group annotations or tags into snapshot plugin tags.
[0079] In the above solution, by configuring the target snapshot plug-in in the container runtime and the container orchestration system, a foundation is laid for the subsequent normal use of the target snapshot plug-in in the container runtime and the container orchestration system.
[0080] In some embodiments of the present disclosure, the container management method further includes: receiving a read request for a second file in a shared file directory of the target container; downloading the second file from the shared file system to the shared file directory and returning the file.
[0081] The second file may be a file to be read and not modified that is recorded in the shared file directory. This embodiment does not limit the number and type of the second file. The read request may be a request to read the second file.
[0082] In this embodiment, after the target container is started, if a process in the target container needs to read a second file in the shared file directory, the process can send a read request for the second file to the container management device. After receiving the read request for the second file, the container management device downloads the second file from the shared file system to the shared file directory of the read-only layer according to the write-on-write feature of the write-on-write file system, and returns the second file to the process that sent the read request.
[0083] In the above solution, the reading of files recorded in the shared file directory is realized.
[0084] Next, the container management method in the embodiment of the present disclosure is further illustrated by using a specific example.
[0085] In this embodiment, the snapshot plug-in tag may be obtained through a container orchestration system, or may be obtained through a remote procedure call service during container runtime.
[0086] Specifically, the process of obtaining snapshot plugin labels through the container orchestration system includes: pre-declaring a target annotation in the container group's annotation, and then invoking the container runtime interface service of the container runtime through the container orchestration system according to the container runtime interface. The container runtime interface service of the container runtime converts the target annotation of the container group into a snapshot plugin label.
[0087] The process of obtaining the snapshot plug-in label through the remote procedure call service of the container runtime includes: the container management device calls the remote procedure call service of the container runtime to obtain the snapshot plug-in label.
[0088] The target snapshot plug-in in this embodiment is implemented based on the write-time multiplexing file system Snapshotter during container runtime. The target snapshot plug-in specifies an additional directory through the snapshot plug-in label, and then adds the shared file directory corresponding to the snapshot plug-in label to the read-only layer parameter of the write-time multiplexing file system mount parameter.
[0089] Specifically, when creating the target container and constructing the RootFS, the container runtime calls the configuration declaration Snapshotter Plugin. If the Snapshotter Plugin finds a snapshot plugin tag, it adds the value of the snapshot plugin tag to the front of the LowerDir parameter of the Options of mounts[0] returned by the write-time multiplexing file system.
[0090] Configure the target snapshot plugin in the container runtime. Specifically, compile the configuration code and start the Snapshotter plugin. In the container runtime configuration, configure the Snapshotter plugin to use it. Restart the container runtime.
[0091] Configure the target snapshot plugin in the container orchestration system. Specifically, declare the target snapshot plugin in the configuration file. Define the key and semantics of the corresponding container group annotation or label. Modify the container creation logic of the container runtime interface and convert the container group annotation or label of the container orchestration system into a snapshot plugin label in the source code.
[0092] The container management method provided by the embodiment of the present disclosure enhances the functionality of the container, and enables a process in a certain container to modify shared files between containers, but the modification of the shared files by the container is not visible to other containers. The background can add shared files to the shared file directory, and the newly created containers can also see the newly added shared files, which realizes the convenient management of shared files, avoids the storage of shared files in each container separately, and reduces storage redundancy. In addition, by mounting, it is avoided that all shared files are downloaded to the container when the container is started, and a significant increase in the time consumed in container startup is avoided.
[0093] FIG5 is a schematic diagram of the structure of a container management device provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware and can generally be integrated into an electronic device. As shown in FIG5 , the container management device includes:
[0094] A directory adding module 501 is configured to add a shared file directory to the read-only layer of the root file system of the target container during the creation of the target container, wherein the shared file directory is a mount directory of the shared file system;
[0095] A first request receiving module 502 is configured to receive a request to modify a first file in the shared file directory of the target container;
[0096] The file modification module 503 is configured to download the first file from the shared file system to the shared file directory, copy the first file from the shared file directory to the read-write layer, and perform modification operations on the first file in the read-write layer.
[0097] In some embodiments of the present disclosure, the directory adding module 501 includes:
[0098] An acquisition submodule, configured to acquire a snapshot plug-in tag during creation of the target container, wherein the snapshot plug-in tag includes a mount directory of the shared file system;
[0099] A submodule is added to call the target snapshot plug-in, and based on the snapshot plug-in label, a mount directory of the shared file system is added as a shared file directory in the read-only layer of the root file system of the target container.
[0100] In some embodiments of the present disclosure, the acquisition submodule is used to:
[0101] Obtaining a target annotation including the volume number of the shared file system, and determining that the mount directory of the volume number is the mount directory of the shared file system;
[0102] A container runtime interface service is called to convert the target annotation into a snapshot plug-in label including the mount directory of the shared file system.
[0103] In some embodiments of the present disclosure, the acquisition submodule is used to:
[0104] Get the snapshot plugin tag through a remote call service.
[0105] In some embodiments of the present disclosure, the container management device further includes:
[0106] A code adding module is used to add a configuration code of a snapshot plug-in tag to the code of the target snapshot plug-in, wherein the configuration code of the snapshot plug-in tag is used to add the value of the snapshot plug-in tag to the options of the read-only layer of the copy-on-write file system corresponding to the root file system, and the root file system is constructed based on the copy-on-write file system.
[0107] In some embodiments of the present disclosure, the container management device further includes:
[0108] The plug-in configuration module is used to configure and use the target snapshot plug-in in the container runtime and the container orchestration system.
[0109] In some embodiments of the present disclosure, the container management device further includes:
[0110] a second request receiving module, configured to receive a read request for a second file in the shared file directory of the target container;
[0111] The file download module is used to download the second file from the shared file system to the shared file directory and return it.
[0112] The container management device provided in the embodiments of the present disclosure can execute the container management method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0113] A computer program product includes a computer program / instruction, wherein the computer program / instruction implements the steps of the container management method when executed by a processor.
[0114] FIG6 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure.
[0115] 6 , which illustrates a schematic diagram of the structure of an electronic device 600 suitable for implementing embodiments of the present disclosure. The electronic device 600 in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. The electronic device illustrated in FIG6 is merely an example and should not limit the functionality or scope of use of the embodiments of the present disclosure.
[0116] As shown in Figure 6, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the electronic device 600 are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0117] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although FIG. 6 shows the electronic device 600 with various devices, it should be understood that not all of the devices shown are required to be implemented or present. More or fewer devices may alternatively be implemented or present.
[0118] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product that includes a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the container management method of the embodiment of the present disclosure are performed.
[0119] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0120] In some embodiments, the client and server can communicate using any currently known or later developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or later developed network.
[0121] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0122] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device is caused to: add a shared file directory in the read-only layer of the root file system of the target container during creation of the target container, wherein the shared file directory is a mount directory of the shared file system; receive a modification request for a first file in the shared file directory of the target container; download the first file from the shared file system to the shared file directory, copy the shared file directory to the read-write layer, and perform a modification operation on the first file in the read-write layer.
[0123] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0124] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0125] The units involved in the embodiments described in this disclosure may be implemented in software or hardware, wherein the name of a unit does not necessarily limit the unit itself.
[0126] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0127] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0128] It is understandable that before using the technical solutions disclosed in the embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the information involved in this disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0129] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0130] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0131] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A container management method, comprising: During the creation of the target container, a shared file directory is added to the read-only layer of the root file system of the target container, wherein the shared file directory is a mount directory of the shared file system; receiving a modification request for a first file in the shared file directory of the target container; The first file is downloaded from the shared file system to the shared file directory, and copied from the shared file directory to the read-write layer, and the first file is modified in the read-write layer.
2. The method according to claim 1, wherein During the creation of the target container, adding a shared file directory to the read-only layer of the root file system of the target container includes: During the creation of the target container, obtaining a snapshot plug-in label, wherein the snapshot plug-in label includes a mount directory of the shared file system; The target snapshot plug-in is called, and based on the snapshot plug-in label, a mount directory of the shared file system is added as a shared file directory in the read-only layer of the root file system of the target container.
3. The method according to claim 2, wherein: The method of obtaining a snapshot plugin tag includes: Obtaining a target annotation including the volume number of the shared file system, and determining that the mount directory of the volume number is the mount directory of the shared file system; A container runtime interface service is called to convert the target annotation into a snapshot plug-in label including the mount directory of the shared file system.
4. The method according to claim 2, wherein: The method of obtaining a snapshot plugin tag includes: Get the snapshot plugin tag through a remote call service.
5. The method according to claim 2, characterized in that The method further comprises: Add the configuration code of the snapshot plug-in tag to the code of the target snapshot plug-in. In the configuration code of the snapshot plug-in tag, the value of the snapshot plug-in tag is used to add the option of the read-only layer of the copy-on-write file system corresponding to the root file system, and the root file system is constructed based on the copy-on-write file system.
6. The method according to claim 5, further comprising: The target snapshot plug-in is configured and used in the container runtime and container orchestration system.
7. The method according to claim 1, further comprising: receiving a read request for a second file in the shared file directory of the target container; The second file is downloaded from the shared file system to the shared file directory and returned.
8. A container management method, comprising: A directory adding module, configured to add a shared file directory to the read-only layer of the root file system of the target container during the creation of the target container, wherein the shared file directory is a mount directory of the shared file system; A first request receiving module, configured to receive a request to modify a first file in the shared file directory of the target container; The file modification module is used to download the first file from the shared file system to the shared file directory, copy the first file from the shared file directory to the read-write layer, and perform modification operations on the first file in the read-write layer.
9. An electronic device, comprising: processor; a memory for storing instructions executable by the processor; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the container management method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the container management method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program / instruction, wherein when the computer program / instruction is executed by a processor, the steps of the container management method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Container mirror image file processing method and device, equipment and storage medium
CN114281480A
File system sharing method and device, electronic equipment and storage medium
CN116150116A
File mounting method and device and electronic equipment
CN116303309A
Operation method and device of file system, storage medium and electronic equipment
CN117687964A
Container management method and device, equipment and medium
CN118132203A