Method, device, and computer program product for managing container images

By setting the expiration time for the image layer in the host device, dynamically managing the storage of the image layer, solving the problem of large storage resources and bandwidth overhead in the prior art, realizing more efficient container image management, and reducing the need for remote downloads.

CN113934506BActive Publication Date: 2025-08-08EMC IP HLDG CO LLC
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202010610469.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-29
Publication Date
2025-08-08
Estimated Expiration
2040-06-29

AI Technical Summary

Technical Problem

In the prior art, when managing container images, there is a problem that storage resources and bandwidth overhead are high and the possibility of download failure is high. Especially when the types and number of containers increase, how to effectively manage container images has become a research hotspot.

Method used

Set the expiration time for each image layer in the host device, dynamically adjust the expiration time according to the attributes of the image layer such as hierarchy, size, number of replicas and recent access time, and delete the image layer when it expires, using the host device as the cache of the image layer to reduce the need for remote downloads.

Benefits of technology

By dynamically managing the storage of the image layer, the bandwidth and time overhead of downloading the image layer from the remote image server are reduced, storage space utilization is optimized, and the efficiency and reliability of container image management are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113934506B_ABST
    Figure CN113934506B_ABST
Patent Text Reader

Abstract

The present disclosure relates to methods, devices, and computer program products for managing images of containers. In a method for managing images of containers in a host device, a first image of a first container is received, the first image including a first set of image layers respectively used to implement a first set of services of the first container. The first image is loaded to deploy the first container at the host device. An expiration time is set for the image layer based on attributes of the image layer in the first set of image layers. In response to determining that the expiration time is met, the image layer is deleted from the host device. Corresponding devices and computer program products are provided. Using an exemplary implementation of the present disclosure, an expiration time is set for each image layer of the image. In this way, each image layer can be stored in the host device. When a new container is deployed to a host device in a host cluster, the stored image layers can be reused to reduce the transmission bandwidth for downloading the image layers from a remote location.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Implementations of the present disclosure relate to container management, and more particularly, to methods, devices, and computer program products for managing container images in a host device. Background Art

[0002] With the development of computer technology, "container" technology has been widely adopted across multiple industries. Currently, an increasing number of applications are developed based on container technology. A container, in this context, is a technology used to encapsulate services, allowing developers to encapsulate the various services associated with an application. Furthermore, various types of containers can serve as modules for subsequent development. For example, an application can be developed based on one or more containers.

[0003] A container image can be downloaded from a server that provides the container. This image can be loaded onto a host device to deploy the container there. Depending on the container's functionality, the size of a container image can vary significantly, ranging from tens of KB to several GB. Consequently, storing and downloading images incurs significant storage and bandwidth overhead. Therefore, managing container images more efficiently has become a research hotspot. Summary of the Invention

[0004] Therefore, it is desirable to develop and implement a technical solution for managing container images in a more efficient manner. It is desirable that the technical solution be compatible with existing application environments and manage container images in a more efficient manner by modifying various configurations of existing application environments.

[0005] According to a first aspect of the present disclosure, a method for managing container images on a host device is provided. In the method, a first image for a first container is received, the first image including a first set of image layers for respectively implementing a first set of services for the first container. The first image is loaded to deploy the first container on the host device. An expiration time is set for the image layer based on attributes of an image layer in the first set of image layers. In response to determining that the expiration time has been met, the image layer is deleted from the host device.

[0006] According to a second aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; a volatile memory; and a memory coupled to the at least one processor, the memory having instructions stored therein, which, when executed by the at least one processor, cause the electronic device to perform actions for managing images of containers on a host device. The actions include: receiving a first image of a first container, the first image comprising a first set of image layers respectively configured to implement a first set of services of the first container; loading the first image to deploy the first container on the host device; setting an expiration time for the image layer based on attributes of the image layer in the first set of image layers; and deleting the image layer from the host device in response to determining that the expiration time has been met.

[0007] According to a third aspect of the present disclosure, there is provided a computer program product tangibly stored on a non-transitory computer-readable medium and comprising machine-executable instructions for executing the method according to the first aspect of the present disclosure.

[0008] According to a fourth aspect of the present disclosure, there is provided a computer program product, which is tangibly stored on a non-transitory computer-readable medium and comprises machine-executable instructions for executing the method according to the second aspect of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] The features, advantages and other aspects of the various implementations of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings, which illustrate several implementations of the present disclosure in an illustrative and non-limiting manner. In the accompanying drawings:

[0010] Figure 1 A block diagram schematically illustrates an application environment in which implementations of the present disclosure may be applied;

[0011] Figure 2 A block diagram schematically illustrates a process for managing container images in a host device according to an implementation of the present disclosure;

[0012] Figure 3 A flowchart of a method for managing container images in a host device according to an implementation of the present disclosure is schematically shown;

[0013] Figure 4 A block diagram schematically illustrates a hierarchy of image layers according to an implementation of the present disclosure;

[0014] Figure 5 A block diagram schematically illustrates a process for obtaining an image of a new container according to an implementation of the present disclosure;

[0015] Figure 6A block diagram schematically illustrates a topology structure between hosts in a host cluster according to an implementation of the present disclosure;

[0016] Figure 7A A block diagram schematically illustrates a process for deploying a new container according to an implementation of the present disclosure;

[0017] Figure 7B A block diagram schematically illustrates a process for deploying a new container according to one implementation of the present disclosure; and

[0018] Figure 8 A block diagram schematically illustrates a device for managing container images in a host device according to an exemplary implementation of the present disclosure. DETAILED DESCRIPTION

[0019] The following describes preferred implementations of the present disclosure in more detail with reference to the accompanying drawings. Although preferred implementations 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 limited by the implementations described herein. Rather, these implementations are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.

[0020] As used herein, the term "including" and its variations represent open inclusion, i.e., "including but not limited to." Unless otherwise stated, the term "or" means "and / or." The term "based on" means "based at least in part on." The terms "an example implementation" and "an implementation" mean "at least one example implementation." The term "another implementation" means "at least one additional implementation." The terms "first," "second," etc. may refer to different or the same objects. Other explicit and implicit definitions may also be included below.

[0021] With the development of cloud technology, more and more applications are developed based on container technology. As the types and number of containers gradually increase, image servers have been established to manage container images. Figure 1 A block diagram 100 schematically illustrates an application environment in which implementations of the present disclosure may be applied. Figure 1 As shown, image server 110 may store multiple container images 112, ..., and 114, etc. The application environment may include one or more host clusters 150, and host cluster 150 may include multiple host devices 130, ..., and 140. A host device may download a desired image from image server 110 via network 120. For example, host device 130 may download an image from image server 110 to form image 132 in host device 130. Image 132 may be loaded to deploy container 134 in host device 130.

[0022] As will be appreciated, image sizes can vary significantly. A simple container image might be only tens of KB, while a complex container image might reach several GB. In this case, the host device must download the image from the remote image server 110 via network 120, which results in significant bandwidth usage. Furthermore, network conditions can be unstable, further increasing the likelihood of download failures.

[0023] It will be understood that an image can include one or more image layers. Currently, technical solutions have been proposed for managing images in a distributed manner based on image layers. However, image layers can vary greatly in size. Downloading multiple image layers from a remote location still consumes significant communication bandwidth. With the increasing variety and number of containers, managing container images in a more reliable and efficient manner has become a research hotspot.

[0024] In order to at least partially solve the problems in the existing technical solutions, according to the exemplary implementation of the present disclosure, a method, device and computer program product for managing container images are proposed. Figure 2 Exemplary embodiments of the present disclosure are generally described. Figure 2 A block diagram 200 schematically illustrates a process for managing container images in a host device according to one implementation of the present disclosure. Figure 2 As shown, host device 130 can download an image from image server 110 via network 120 and store the image in a storage space in host device 130 to form image 132. After image 132 is loaded and a corresponding container is deployed, image 132 is not directly deleted. Instead, an expiration time is set for each image layer in image 132. When the expiration time of a certain image layer is reached, the image layer is deleted.

[0025] like Figure 2 As shown, image 132 may include multiple image layers 210, 212, and 214, etc. Similarly, host device 140 may download an image from image server 110 to form image 230 in host device 40. Image 230 may include multiple image layers 240, 242, and 244, etc. It will be understood that the various image layers stored in host device 130 may be accessed by various host devices in host cluster 150 (including host device 130 and other host devices such as host device 140, etc.).

[0026] Using the exemplary implementations of the present disclosure, host device 130 can act as a cache for each image layer. In this way, when a host device in host cluster 150 needs to use a certain image layer to deploy a new container, it can first search within host cluster 150 to determine whether the image layer exists. If so, the image layer can be retrieved directly from within host cluster 150, thereby avoiding downloading the image layer from remote image server 110 via network 120. It will be appreciated that since each host device is located within host cluster 150, significant bandwidth exists between the hosts. This approach can significantly reduce the time overhead of retrieving image layers from remote locations.

[0027] In the following, we will refer to Figure 3 Describes in more detail a method for managing container images. Figure 3 A flowchart of a method 300 for managing container images in a host device according to an implementation of the present disclosure is schematically shown. At block 310, a first image of a first container is received, the first image including a first set of image layers for implementing a first set of services of the first container. Here, the first container may be, for example, an application providing network communication functionality, and the first image may include: Figure 2 Multiple image layers are shown: an image layer 210 for providing operating system (OS) services; an image layer 212 for providing network-related services; and an image layer 214 for providing interface-related services, etc.

[0028] It will be understood that the multiple image layers described above are merely illustrative. Based on the functionality of the first container, the first set of image layers may include more, fewer, or different image layers. For example, for a container providing storage functionality, the container's image may include an image layer providing OS services, an image layer providing storage services, and an image layer providing interface services.

[0029] Continue to see Figure 3 At block 320 , the first image is loaded to deploy the first container on host device 130 . It will be appreciated that the loading process can be performed according to existing technical solutions. By loading the first image onto host device 130 , a first container for providing the corresponding functionality can be deployed on host device 130 . It will be appreciated that an image is similar to an installation program; once the image has been loaded and the first container has been successfully deployed, the image has completed its functionality.

[0030] According to an exemplary implementation of the present disclosure, the host device 130 can be used as a cache for downloading images from the remote image server 110. In other words, the first image in the host device 130 can be reused to serve the host devices in the host cluster 150, so that other host devices can find out whether there is a reusable image layer from the first image. According to an exemplary implementation of the present disclosure, after the first container has been successfully deployed, the first image is not directly deleted, but an expiration time is set for each of the multiple image layers in the first image. Before the expiration time is reached, the corresponding image layer can be kept in the host device 130. In the following, see Figure 3 Block 330 in describes further details regarding setting the expiration time.

[0031] exist Figure 3 At block 330, an expiration time is set for the image layer based on attributes of the image layer in the first set of image layers. It will be appreciated that an image layer can have various attributes, including but not limited to: the image layer's level, size, number of concurrent provisioning requests, number of replicas, and last access time. Expiration times can be set based on each of these attributes.

[0032] According to an exemplary implementation of the present disclosure, the expiration time can be set based on the level of the image layer. Specifically, the expiration time can be set to be inversely proportional to the level. Figure 4 Describes the concept of a hierarchy of image layers. Figure 4 A block diagram 400 schematically illustrates the hierarchy of image layers according to one implementation of the present disclosure. It will be understood that an image is not a monolithic structure, but may include multiple layers of image layers. Generally speaking, the lower the image layer, the more basic the services provided; the higher the image layer, the more specialized the services provided. Figure 4 As shown, the level of the image layer 210 for providing OS services can be set to 1, the level of the image layer 242 for providing storage services can be set to 2, the level of the image layer 212 for providing network services can be set to 3, and the level of the image layer 214 for providing interface services can be set to 4, and so on.

[0033] will understand, Figure 4The hierarchical settings of several image layers that may be included in the image are only schematically shown. According to the exemplary implementation of the present disclosure, the image may include more, fewer, or different image layers, and each image layer may have a different hierarchy. Generally speaking, image layers with lower hierarchies are used more frequently. For example, the image layer 210 that provides OS services is the basis of the container, and almost every container uses the image layer 210. Therefore, a longer expiration time can be set for the image layer 210. For another example, each container can have a different interface, and the image layer 214 that provides a certain interface service is less likely to be used by other containers. Therefore, a shorter expiration time can be set for the image layer 214.

[0034] According to an exemplary implementation of the present disclosure, the symbol l can be used to represent the level of the image layer. At this time, the expiration time time of the image layer can be determined based on the following formula 1:

[0035]

[0036] Where time represents the expiration time of the image layer, l represents the level of the image layer, and f represents a predetermined function. It will be understood that Formula 1 above is merely illustrative, and those skilled in the art may configure the specific formula of function f based on the requirements of a specific application environment, as long as the formula is inversely proportional to the variable l.

[0037] Using the exemplary implementation of the present disclosure, a longer expiration time is set for more general image layers, and a shorter expiration time is set for more specialized image layers. In this way, the limited storage space in the host device can be used to store as many image layers as possible that are likely to be used by more containers, thereby reducing the need to obtain image layers from outside the host cluster 150.

[0038] According to an exemplary implementation of the present disclosure, an expiration time can be set based on the size of the image layer. Here, the expiration time can be set proportional to the size. It will be understood that if the size of the image layer is large, downloading the image layer from the remote image server 110 will consume more bandwidth and time. According to an exemplary implementation of the present disclosure, image layers with larger sizes can be preferentially stored. The symbol s can be used to represent the size of the image layer. In this case, the expiration time time of the image layer can be determined based on the following formula 2:

[0039] time = f(log(s)) Formula 2

[0040] Where time represents the expiration time of the image layer, s represents the size of the image layer, and f represents a predetermined function. It will be appreciated that due to the wide range of image layer sizes, the function log(s) is used here to reduce the impact of variable s on the expiration time. It will be appreciated that Formula 2 above is merely illustrative, and those skilled in the art can customize the specific formula for function f based on the requirements of their specific application environment, as long as the formula is proportional to variable s.

[0041] According to an exemplary implementation of the present disclosure, the above formulas 1 and 2 may be combined to determine the expiration time of the image layer based on the following formula 3, where the meaning of each variable is the same as that in formulas 1 and 2.

[0042]

[0043] Using the exemplary implementations of the present disclosure, a longer expiration time can be set for larger image layers, while a shorter expiration time can be set for smaller image layers. For smaller image layers, even if the image layer does not exist in the host cluster 150, downloading it from the remote image server 110 does not consume excessive bandwidth or download time. In this way, the limited storage space on the host device can be utilized to store as many larger image layers as possible, thereby reducing the bandwidth and download time overhead caused by downloading from the remote image server 110.

[0044] According to an exemplary implementation of the present disclosure, an expiration time can be set based on the number of parallel provisioning of the image layer, where the expiration time can be proportional to the number of parallel provisioning. It will be understood that the number of parallel provisioning indicates how many other host devices in the host cluster can access the image layer in parallel at most. Based on the topology of the host cluster 150, the host device can be connected to one or more other host devices. For example, the host device 130 can be connected to three other host devices in parallel. At this time, the number of parallel provisioning of the image layer in the host device 130 is 3. The symbol p can be used to represent the number of parallel provisioning of the image layer. At this time, the expiration time time of the image layer can be determined based on the following formula 4:

[0045] time = f(p) Formula 4

[0046] Where time represents the expiration time of the image layer, p represents the number of concurrently provided image layers, and f represents a predetermined function. It will be understood that Formula 4 above is merely illustrative, and those skilled in the art may customize the specific formula of function f based on the requirements of a specific application environment, as long as the formula is proportional to the variable p.

[0047] According to an exemplary implementation of the present disclosure, the above formulas 1 to 4 may be combined and the expiration time of the image layer may be determined based on the following formula 5, where the meaning of each variable is the same as that in formulas 1 to 4.

[0048]

[0049] Using the exemplary implementations of the present disclosure, a greater number of concurrently provided image layers indicates that the image layer can be concurrently accessed by more host devices. By setting a longer expiration time for image layers with a greater number of concurrently provided image layers, image layers that can be accessed by more other host devices can be preferentially stored on host devices. This reduces the bandwidth and time required to download image layers from remote image servers 110 outside of host cluster 150.

[0050] According to an exemplary implementation of the present disclosure, an expiration time may be set based on the number of copies of the image layer included in the host cluster. Specifically, the expiration time may be set to be inversely proportional to the number of copies. It will be understood that the number of copies represents the total number of copies of the image layer included in the host cluster 150. If the number of copies is large, deleting an image layer will not have a significant impact on the number of copies; if the number of copies is small, deleting an image layer will significantly reduce the number of copies. Thus, a shorter expiration time may be set for an image layer with a larger number of copies, and a longer expiration time may be set for an image layer with a smaller number of copies. The symbol n may be used to represent the number of copies of an image layer. At this point, the expiration time time of the image layer may be determined based on the following formula 6:

[0051] time=f(e -n ) Formula 6

[0052] Where time represents the expiration time of the image layer, n represents the number of copies of the image layer, and f represents a predetermined function. It will be understood that since the range of the number of copies of the image layer is large, the function e is used here. -n It will be understood that the above formula 6 is merely illustrative, and those skilled in the art can set the specific formula of function f according to the requirements of the specific application environment, as long as the formula is inversely proportional to the variable n.

[0053] According to an exemplary implementation of the present disclosure, the above formulas 1 to 6 may be combined and the expiration time of the image layer may be determined based on the following formula 7, where the meaning of each variable is the same as that in formulas 1 to 6.

[0054]

[0055] By using the exemplary implementation of the present disclosure, a longer expiration time is set for image layers with a smaller number of replicas, so that image layers with only a small number of replicas can be preferentially stored on the host device. In this way, the limited storage space of the host cluster can be used to store more diverse image layers, thereby reducing the need to download image layers from remote image servers 110 outside the host cluster 150.

[0056] According to an exemplary implementation of the present disclosure, an expiration time can be set based on the difference between the current time and the time when the image layer was last accessed. Specifically, the expiration time can be set to be inversely proportional to the difference. Here, the expiration time can be set based on the least recently used principle. A larger difference indicates that the image layer has not been accessed for a long period of time, so it can be deleted. A smaller difference indicates that the image layer has just been accessed recently, so it needs to be retained. The symbol Δt can be used to represent the time difference. At this time, the expiration time time of the image layer can be determined based on the following formula 8:

[0057]

[0058] Where time represents the expiration time of the image layer, n represents the number of copies of the image layer, and f represents a predetermined function. It will be understood that the above formula 8 is merely illustrative, and those skilled in the art can set the specific formula of function f according to the requirements of the specific application environment, as long as the formula is inversely proportional to the variable Δt.

[0059] By using the exemplary implementation of the present disclosure, by setting a longer expiration time for image layers that have been frequently accessed recently, more popular image layers can be preferentially stored on the host device. In this way, the limited storage space of the host cluster can be used to store image layers that are more easily accessed, thereby reducing the need to download image layers from remote image servers 110 outside the host cluster 150.

[0060] According to an exemplary implementation of the present disclosure, an image layer can be accessed by the local host device storing the image layer, and can also be accessed by host devices other than the local host device. Therefore, the time when the image layer was most recently accessed includes at least one of the following: the time when the host device most recently accessed the image layer, and the time when another host device in the host cluster most recently accessed the image layer. The time when the image layer was most recently accessed can be determined based on either of the two times. For example, either time can be selected from the two times, either the earlier time or the later time.

[0061] According to an exemplary implementation of the present disclosure, if an image layer in a host device is accessed, the expiration time of the image layer can be updated. Using this exemplary implementation, the expiration time of an image layer can be dynamically adjusted to store the most popular image layers in the host device.

[0062] Using the exemplary implementations of the present disclosure, we can consider both local access by a local host device and remote access by other host devices in host cluster 150. The access time for both local and remote access can represent the popularity of an image layer. In this way, the limited storage space of the host cluster can be utilized to store highly popular image layers, thereby reducing the need to download image layers from remote image servers 110 outside of host cluster 150.

[0063] According to an exemplary implementation of the present disclosure, the above formulas 1 to 8 can be combined and the expiration time of the image layer can be determined based on the following formula 9, where the meaning of each variable is the same as that in formulas 1 to 8.

[0064]

[0065] In the above, reference has been made to Formulas 1 through 9 to describe how to determine the expiration time of an image layer. It will be understood that Formulas 1 through 9 merely illustrate examples of the relationship between the expiration time and various attributes of the image layer. According to exemplary implementations of the present disclosure, other formulas may be configured based on specific application environments.

[0066] In the following, we will return Figure 3 More details are described for managing image layers based on expiration times. At block 340, if it is determined that the expiration time has been met, the image layer is deleted from the host device. According to an exemplary implementation of the present disclosure, reaching the expiration time indicates that the likelihood of the image layer being accessed in the future has greatly decreased, and thus the image layer can be deleted from the host device. Utilizing the exemplary implementation of the present disclosure, the expiration time of each image layer can be continuously updated as each host device in host cluster 150 operates, and expired image layers can be deleted. In this way, it is possible to ensure that stored images do not occupy excessive storage space on the host device, thereby ensuring the overall performance of the host device.

[0067] According to an exemplary implementation of the present disclosure, one or more image layers stored at a host device may be reused. Specifically, if an instruction to deploy a second container at the host device is received, a second set of image layers for implementing a second set of services of the second container may be determined. Subsequently, it may be determined whether an image layer in the second set of image layers is included at the host device. If the host device includes an image layer in the second set of image layers, the specified image layer may be directly reused. hereinafter, see Figure 5Describe in more detail.

[0068] Figure 5 A block diagram 500 schematically illustrates a process of obtaining a new container image according to an implementation of the present disclosure. Figure 5 In the example, assume that the new container image 510 should include four image layers: an image layer for interface services, an image layer for network services, an image layer for storage services, and an image layer for the OS. In this case, the host device 130 can first be checked to see whether these image layers exist. Assuming that all image layers stored in the host device 130 have not expired, the host device 130 includes the image layer 214 for interface services, the image layer 212 for network services, and the image layer 210 for the OS.

[0069] At this point, the aforementioned image layers can be reused. As indicated by arrow 534, locally stored image layer 214 can be used to form image layer 524 in image 510; as indicated by arrow 532, locally stored image layer 212 can be used to form image layer 522 in image 510; and as indicated by arrow 530, locally stored image layer 210 can be used to form image layer 520 in image 510.

[0070] According to an exemplary implementation of the present disclosure, host device 130 does not include the image layer required for storage for deploying a new container. In this case, the image layer can be obtained from another host device (e.g., host device 140) in host cluster 150. As shown by arrow 536, image layer 242 stored in host device 140 can be used to form image layer 526 in image 510. At this point, host device 130 already includes all image layers for deploying the new container, so image 510 can be started to deploy the new container on host device 130.

[0071] According to an exemplary implementation of the present disclosure, a unified distributed storage system for image layers can be established using the image layers stored on the host devices in the host cluster 150. Through the network connection within the host cluster 150, the host devices can share the image layers in the distributed storage system, thereby reducing the need to download image layers from outside the host cluster 150.

[0072] Using the exemplary implementations of the present disclosure, image layers can be reused from either the local host device or other host devices in host cluster 150. It will be appreciated that the host devices in host cluster 150 are located in close proximity to one another, and therefore, regardless of accessing image layers from the local host device or from other host devices, the desired image layer can be quickly obtained. In this way, downloading image layers from remote image server 110 over the network can be minimized.

[0073] According to an exemplary implementation of the present disclosure, in order to obtain a specified image layer from other host devices, a topology structure representing the connection between the host device and other host devices in the host cluster can be first obtained. In the context of the present disclosure, the topology structure can be represented in a variety of ways. For example, the topology structure can be represented via a distributed hash table (DHT). A distributed hash table can be set for each host device, and the universally unique identifier (UUID) of another host device connected to the host device can be recorded in the distributed hash table, and the path between the host device and the other host device can be recorded (for example, represented by "hops").

[0074] In the following, we will refer to Figure 6 Describe with more details. Figure 6 A block diagram 600 schematically illustrates a topology structure between various hosts in a host cluster according to an implementation of the present disclosure. Figure 6 As shown, host device 130 is connected to host devices 140 and 610, and host device 610 is connected to host device 620. At this time, the distributed hash table of host device 130 may include the following entries: the first entry includes the UUID of host device 140 and the path from host device 130 to host device 140 (1 hop); the second entry includes the UUID of host device 610 and the path from host device 130 to host device 610 (1 hop); and the third entry includes the UUID of host device 620 and the path from host device 130 to host device 620 (2 hops).

[0075] According to an exemplary implementation of the present disclosure, the host device 130 may obtain a specified image layer from other host devices via a distributed hash table. The host device 130 may choose to query a host device that is logically closer. If the queried host device has the specified image layer, the queried image layer may be returned to the host device 130. If the queried host device does not have the specified image layer, the query request may be forwarded to other host devices. For example, if the host device 610 does not have the specified image layer, the query request from the host device 130 may be forwarded to the host device 620. If the host device 620 has the specified image layer, the queried image layer may be returned to the host device 130 via the host device 610.

[0076] Using the exemplary implementations of this disclosure, a host device can directly use an existing distributed hash table to query connected host devices for the desired image layer. This allows the desired image layer to be obtained preferentially within host cluster 150, thereby reducing bandwidth requirements for communication with hosts outside of host cluster 150.

[0077] Figure 7A A block diagram 700A schematically illustrates a process for deploying a new container according to one implementation of the present disclosure. Figure 7A As shown, host device 130 may receive 710 an indication for deploying a new container and may determine 712 a plurality of image layers corresponding to the new container. Host device 130 may then locally search 714 for each of the plurality of image layers one by one. If the specified image layer is found locally, the specified image layer may be reused. If the specified image layer is not found locally, a request to obtain the specified image layer may be sent 716 to another host device (e.g., host device 140). Upon receiving the request, host device 140 may locally search 718 for the existence of the specified image layer. If the determination result is “yes”, the specified image layer may be returned 720 to host device 130. After all the plurality of image layers have been obtained, host device 130 may load 722 the plurality of image layers in order to deploy the new container.

[0078] will understand, Figure 7A The schematic diagram shows an example of locally searching 714 a designated image layer on the host device 130 and obtaining the designated image layer from the host device 140. The above steps may be performed for each designated image layer, so as to obtain each image layer in the plurality of image layers.

[0079] According to an exemplary implementation of the present disclosure, if the host cluster 150 does not include a specified image layer, the specified image layer can be obtained from the image server 110. Figure 7B Provide more details. Figure 7B A block diagram 700B schematically illustrates a process for deploying a new container according to an implementation of the present disclosure. Figure 7B In steps 710 to 718, Figure 7A The same as shown in , so no further description is given.

[0080] If the specified image layer is not included in host device 140, host device 140 may forward the request from host device 130 to other host devices (not shown). If the specified image layer is not included in host cluster 150, host device 140 may return 724 "NULL" to host device 130. At this point, host device 130 may send 726 a request to image server 110 to obtain the specified image layer. Image server 110 will find 728 the specified image layer and return 730 the specified image layer to host device 130. After all multiple image layers have been obtained, host device 130 may load 732 the multiple image layers to deploy a new container.

[0081] Using the exemplary implementations of the present disclosure, host device 130 can preferentially search for image layers for deploying a new image among the various host devices within host cluster 150. If a specific image layer does not exist in host cluster 150, it can be downloaded from a remote image server 110. Compared to existing technical solutions that directly download all image layers from a remote image server 110, the exemplary implementations of the present disclosure can fully utilize the image layers stored within host cluster 150 and only access the remote image server 110 if a specific image layer does not exist in host cluster 150. This reduces the bandwidth required to access the remote image server 110 and reduces the time required to retrieve each image layer.

[0082] It will be understood that the above Figure 7A and Figure 7B The process is merely illustrative. According to the exemplary implementation of the present disclosure, different processes may be adopted based on the specific application environment. For example, when it is found that the host device with a certain image layer is under a high workload (or for other reasons), the image layer may be downloaded directly from the image server 110.

[0083] See above for Figures 2 to 7B An example of the method according to the present disclosure is described in detail, and the implementation of the corresponding device will be described below. According to the exemplary implementation of the present disclosure, a device for managing images of containers in a host device is provided. The device includes: a receiving module configured to receive a first image of a first container, the first image including a first group of image layers respectively used to implement a first group of services of the first container; a loading module configured to load the first image so as to deploy the first container at the host device; a setting module configured to set an expiration time for the image layer based on the attributes of the image layer in the first group of image layers; and a deletion module configured to delete the image layer from the host device in response to determining that the expiration time is met. According to the exemplary implementation of the present disclosure, the device may further include a module for performing other steps in the method described above.

[0084] Figure 8 A block diagram of a device 800 for managing images of containers in a host device according to an exemplary implementation of the present disclosure is schematically shown. As shown, the device 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) 802 or computer program instructions loaded from a storage unit 808 into a random access memory (RAM) 803. In RAM 803, various programs and data required for the operation of the device 800 can also be stored. CPU 801, ROM 802, and RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0085] Various components in device 800 are connected to I / O interface 805, including an input unit 806, such as a keyboard, mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a magnetic disk, optical disk, etc.; and a communication unit 809, such as a network card, modem, wireless communication transceiver, etc. The communication unit 809 allows device 800 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0086] The various processes and procedures described above, such as method 300, may be performed by processing unit 801. For example, in some implementations, method 300 may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 808. In some implementations, part or all of the computer program may be loaded and / or installed onto device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by CPU 801, one or more steps of method 300 described above may be performed. Alternatively, in other implementations, CPU 801 may be configured in any other suitable manner to implement the aforementioned processes / methods.

[0087] According to an exemplary implementation of the present disclosure, an electronic device is provided, comprising: at least one processor; a volatile memory; and a memory coupled to the at least one processor, the memory having instructions stored therein, which, when executed by the at least one processor, cause the electronic device to perform an action for managing an image of a container on a host device. The action comprises: receiving a first image of a first container, the first image comprising a first set of image layers respectively configured to implement a first set of services of the first container; loading the first image to deploy the first container on the host device; setting an expiration time for the image layer based on an attribute of the image layer in the first set of image layers; and, in response to determining that the expiration time has been met, deleting the image layer from the host device.

[0088] According to an exemplary implementation of the present disclosure, setting an expiration time for an image layer includes setting the expiration time based on a level at which the image layer is located, the expiration time being inversely proportional to the level.

[0089] According to an exemplary implementation of the present disclosure, setting an expiration time for an image layer includes setting the expiration time based on a size of the image layer, the expiration time being proportional to the size.

[0090] According to an exemplary implementation of the present disclosure, setting an expiration time for an image layer includes setting an expiration time based on the number of parallel provisioning of the image layer, the expiration time is proportional to the number of parallel provisioning, and the number of parallel provisioning indicates how many other host devices in the host cluster can access the image layer in parallel at most.

[0091] According to an exemplary implementation of the present disclosure, setting an expiration time for an image layer includes setting the expiration time based on the number of replicas of the image layer included in the host cluster, where the expiration time is inversely proportional to the number of replicas.

[0092] According to an exemplary implementation of the present disclosure, setting an expiration time for an image layer includes: setting the expiration time based on a difference between a current time and a time when the image layer was last accessed, the expiration time being inversely proportional to the difference, and the time when the image layer was last accessed includes at least any one of the following: the time when the host device last accessed the image layer; and the time when other host devices in the host cluster last accessed the image layer.

[0093] According to an exemplary implementation of the present disclosure, the action further includes: in response to receiving an instruction to deploy a second container at a host device, determining a second set of image layers for implementing a second set of services for the second container; in response to determining that the host device does not include a specified image layer in the second set of image layers, obtaining the specified image layer from other host devices in the host cluster.

[0094] According to an exemplary implementation of the present disclosure, obtaining a specified image layer from other host devices includes: obtaining a topology structure representing connections between the host device and other host devices in the host cluster; and obtaining the specified image layer from other host devices based on the topology structure.

[0095] According to an exemplary implementation of the present disclosure, the action further includes: in response to determining that the host cluster does not include the specified image layer, obtaining the specified image layer from an image server connected to the host cluster.

[0096] According to an exemplary implementation of the present disclosure, the action further includes: in response to receiving a request for obtaining the image layer from other host devices in the host cluster, providing the image layer to the other host devices; and updating the expiration time of the image layer.

[0097] According to an exemplary implementation of the present disclosure, a computer program product is provided, which is tangibly stored on a non-transitory computer-readable medium and includes machine-executable instructions for performing a method according to the present disclosure.

[0098] According to an exemplary implementation of the present disclosure, a computer-readable medium is provided, wherein machine-executable instructions are stored on the computer-readable medium, and when the machine-executable instructions are executed by at least one processor, the at least one processor implements the method according to the present disclosure.

[0099] The present disclosure may be a method, an apparatus, a system and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present disclosure.

[0100] A computer-readable storage medium can be a tangible device that can hold and store instructions for use by an instruction execution device. A computer-readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: 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), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination thereof. As used herein, a computer-readable storage medium is not to be construed as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through an electrical wire.

[0101] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions to be stored in the computer-readable storage medium in each computing / processing device.

[0102] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, and conventional procedural programming languages such as "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via 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., utilizing an Internet service provider to connect via the Internet). In some implementations, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions, which may be executed by the computer-readable program instructions to implement various aspects of the present disclosure.

[0103] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products implemented according to the present disclosure. It should be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, can be implemented by computer-readable program instructions.

[0104] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, such that when these instructions are executed by the processing unit of the computer or other programmable data processing device, a device is generated that implements the functions / actions specified in one or more blocks in the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, where these instructions cause the computer, programmable data processing device, and / or other device to operate in a specific manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more blocks in the flowchart and / or block diagram.

[0105] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device, so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0106] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple implementations of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a part for a module, program segment or instruction, and a part for a module, program segment or instruction comprises one or more executable instructions for realizing the logical function of the specification. In some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous boxes 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 flow chart, and the combination of the boxes in the block diagram and / or flow chart can be realized by a special hardware-based system that performs the function or action of the specification, or can be realized by a combination of special hardware and computer instructions.

[0107] While various implementations of the present disclosure have been described above, the foregoing description is intended to be illustrative, non-exhaustive, and not limited to the disclosed implementations. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described implementations. The terminology used herein is selected to best explain the principles of the implementations, their practical applications, or improvements to existing technologies, or to enable others skilled in the art to understand the implementations disclosed herein.

Claims

1. A method for managing container images in a host device, comprising: Receiving a first image of a first container, the first image comprising a first set of image layers respectively used to implement a first set of services of the first container; loading the first image to deploy the first container at the host device; setting an expiration time for an image layer in the first group of image layers based on an attribute of the image layer; as well as In response to determining that the expiration time is met, deleting the image layer from the host device; The attributes of the image layer include at least one of the following: the size of the image layer, the number of parallel provision of the image layer, and the number of replicas of the image layer in a host cluster; and Wherein the expiration time is determined at least in part as a function of the property of the mapping layer.

2. The method according to claim 1, wherein setting an expiration time for the image layer comprises: The expiration time is set based on the level of the image layer, and the expiration time is inversely proportional to the level.

3. The method according to claim 1, wherein setting an expiration time for the image layer comprises: The expiration time is set based on the size of the image layer, the expiration time being proportional to the size.

4. The method according to claim 1, wherein setting an expiration time for the image layer comprises: The expiration time is set based on the parallel provision quantity of the image layer, the expiration time is proportional to the parallel provision quantity, and the parallel provision quantity indicates how many other host devices in the host cluster concurrently access the image layer at most.

5. The method according to claim 1 , wherein setting an expiration time for the image layer comprises: The expiration time is set based on the number of replicas of the image layer in the host cluster, the expiration time being inversely proportional to the number of replicas.

6. The method according to claim 1, wherein setting an expiration time for the image layer comprises: The expiration time is set based on a difference between a current time and a time when the image layer was last accessed, the expiration time being inversely proportional to the difference, and the time when the image layer was last accessed includes at least any one of the following: The time when the host device last accessed the image layer; and The time when one or more other host devices in the host cluster last accessed the image layer.

7. The method according to claim 1, further comprising: In response to receiving an indication to deploy a second container at the host device, determining a second set of image layers for implementing a second set of services of the second container; In response to determining that the host device does not include the specified image layer in the second group of image layers, the specified image layer is obtained from one or more other host devices in the host cluster.

8. The method according to claim 7, wherein obtaining the specified image layer from the one or more other host devices comprises: obtaining a topology structure representing connections between the host device and the one or more other host devices in the host cluster; Based on the topology, the specified image layer is obtained from a plurality of other host devices.

9. The method according to claim 7, further comprising: In response to determining that the host cluster does not include the designated image layer, the designated image layer is obtained from an image server connected to the host cluster.

10. The method according to claim 1, further comprising: In response to receiving a request for obtaining the image layer from one or more other host devices in the host cluster, providing the image layer to the one or more other host devices; as well as The expiration time of the image layer is updated.

11. An electronic device comprising: at least one processor; Volatile memory; as well as a memory coupled to the at least one processor, the memory having instructions stored therein, the instructions, when executed by the at least one processor, causing the electronic device to perform actions for managing images of containers in a host device, the actions comprising: Receiving a first image of a first container, the first image comprising a first set of image layers respectively used to implement a first set of services of the first container; loading the first image to deploy the first container at the host device; Setting an expiration time for an image layer in the first group of image layers based on an attribute of the image layer; and In response to determining that the expiration time is met, deleting the image layer from the host device; wherein the attributes of the image layer include at least one of the following: the size of the image layer, the number of parallel provisioning of the image layer, and the number of replicas of the image layer in a host cluster; and Wherein the expiration time is determined at least in part as a function of the property of the mapping layer.

12. The device according to claim 11, wherein setting an expiration time for the image layer comprises: The expiration time is set based on the level of the image layer, and the expiration time is inversely proportional to the level.

13. The device according to claim 11, wherein setting an expiration time for the image layer comprises: The expiration time is set based on the size of the image layer, the expiration time being proportional to the size.

14. The device according to claim 11, wherein setting an expiration time for the image layer comprises: The expiration time is set based on the parallel provision quantity of the image layer, the expiration time is proportional to the parallel provision quantity, and the parallel provision quantity indicates how many other host devices in the host cluster concurrently access the image layer at most.

15. The device according to claim 11, wherein setting an expiration time for the image layer comprises: The expiration time is set based on the number of replicas of the image layer in the host cluster, the expiration time being inversely proportional to the number of replicas.

16. The device according to claim 11, wherein setting an expiration time for the image layer comprises: The expiration time is set based on a difference between a current time and a time when the image layer was last accessed, the expiration time being inversely proportional to the difference, and the time when the image layer was last accessed includes at least any one of the following: The time when the host device last accessed the image layer; and The time when one or more other host devices in the host cluster last accessed the image layer.

17. The apparatus of claim 11, wherein the actions further comprise: In response to receiving an indication to deploy a second container at the host device, determining a second set of image layers for implementing a second set of services of the second container; In response to determining that the host device does not include the specified image layer in the second group of image layers, the specified image layer is obtained from one or more other host devices in the host cluster.

18. The device of claim 17, wherein obtaining the specified image layer from the one or more other host devices comprises: obtaining a topology structure representing connections between the host device and a plurality of other host devices in the host cluster; Based on the topology structure, the specified image layer is obtained from the other host device.

19. The apparatus of claim 17, wherein the actions further comprise: In response to determining that the host cluster does not include the designated image layer, the designated image layer is obtained from an image server connected to the host cluster.

20. A computer program product tangibly stored on a non-transitory computer-readable medium and comprising machine-executable instructions for performing the method according to any one of claims 1-10.

Citation Information

Patent Citations

  • Software container registry inspection

    US20170177877A1

  • Containerized application system graph driver

    US20180189121A1

  • Caching mechanisms for aggregated information calculation and injection for application containers

    US20180246812A1

  • Distributed container image repository service

    US20190347121A1