Container mirror image cleaning method, electronic equipment and storage medium

By calculating the service value and thermal decay parameters of container images, the importance of container images is dynamically assessed, and a target scoring threshold is set to clean up redundant images. This solves the problem of inaccurate container image cleanup strategies in existing technologies and achieves safe and efficient image management.

CN120872508AActive Publication Date: 2025-10-31INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202511405718.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-29
Publication Date
2025-10-31
Estimated Expiration
2045-09-29

AI Technical Summary

Technical Problem

Existing container image cleanup strategies cannot accurately identify whether unused images will still be used in the production environment, posing a risk of accidentally deleting critical service images and causing service interruptions.

Method used

By calculating the number of services associated with a container image and the service creation time, service value parameters are determined. Combined with the shortest idle time, heat decay parameters are calculated to dynamically evaluate the service dependency value and usage status of the image. Target scoring thresholds are set to clean up redundant images.

Benefits of technology

It enables precise cleanup of container images, reduces storage usage, avoids accidental deletion of critical images, and improves the applicability and security of the cleanup strategy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120872508A_ABST
    Figure CN120872508A_ABST
Patent Text Reader

Abstract

The invention discloses a container mirror image cleaning method, electronic equipment and a storage medium, and relates to the technical field of computers, the method comprises the following steps: determining a service value parameter of a target container mirror image according to the number of services taking the target container mirror image as an operation basis and the creation time of each service; calculating a thermal attenuation parameter of the target container mirror image according to the shortest idle time of each service corresponding to the target container mirror image; calculating a target score of the target container mirror image based on the service value parameter and the thermal attenuation parameter; and if the target score of the target container mirror image is less than a preset cleaning threshold, cleaning the target container mirror image. Redundant mirror images can be effectively recognized and cleaned, storage occupation is reduced, meanwhile, protection is provided for long-term low-activity but key container mirror images, mistaken cleaning is avoided, and the applicability of a container cleaning strategy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method for cleaning up container images, an electronic device, and a storage medium. Background Technology

[0002] With the rapid development of cloud computing, container technology has become a core technology cornerstone of modern software development. Containers typically run on statically packaged container images. A container image is a standardized software packaging format that contains all the components required for software operation, such as applications, dependency libraries, and configuration files. Multiple container entities can be created from the same container image, and multiple software services can be created based on these container entities.

[0003] As business scales up, the number of container images and their storage usage grow exponentially. Traditional container image cleanup methods typically combine the usage time of container images and automatically reclaim expired ones, such as deleting container images that have not been used for more than N days. However, this approach cannot determine whether a temporarily unused container image will still be used in the production environment, posing a risk of service interruption due to the accidental deletion of container images for critical services. Summary of the Invention

[0004] This application provides a method for cleaning up container images, which at least solves the problem of low applicability of container image cleaning strategies in related technologies.

[0005] In a first aspect, this application provides a method for cleaning up a container image, comprising: determining a service value parameter of the target container image based on the number of services running on the target container image and the creation time of each service; wherein the service value parameter is positively correlated with the number of services, and the further the current time is from the creation time of the service, the slower the service value parameter increases; calculating a thermal decay parameter of the target container image based on the shortest idle time of each service corresponding to the target container image; the shortest idle time refers to the time difference between the current time and the most recent historical access time of each service; the idle time is positively correlated with the thermal decay parameter; calculating a target score of the target container image based on the service value parameter and the thermal decay parameter; and cleaning up the target container image if the target score of the target container image is less than a preset cleaning threshold.

[0006] In a second aspect, this application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of any of the container image cleanup methods described above.

[0007] In a third aspect, this application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the container image cleanup methods described above.

[0008] In a fourth aspect, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described container image cleanup methods.

[0009] This application calculates service value parameters based on the number of services associated with a container image and the service creation time, enabling accurate assessment of the service dependencies of container images and dynamic quantification of their service dependency value. It also calculates heat decay parameters based on service idle time, reflecting the actual usage status of container images and automatically adapting to business fluctuations. Finally, it effectively identifies and cleans up redundant images based on target scores, reducing storage consumption. Furthermore, it protects long-term inactive but critical container images, preventing accidental cleanup and improving the applicability of container cleanup strategies. Attached Figure Description

[0010] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 An application environment diagram for a container image cleanup method provided in this application embodiment; Figure 2 A flowchart illustrating a method for cleaning up a container image provided in an embodiment of this application; Figure 3 This is a flowchart illustrating the calculation of service value parameters in some embodiments; Figure 4 This is a flowchart illustrating the process of updating service value parameters in some embodiments; Figure 5 This is a flowchart illustrating the calculation of value sacrifice parameters in some embodiments; Figure 6 This is a flowchart illustrating the calculation of the target score in some embodiments; Figure 7 This is a diagram showing the internal structure of a computer device in some embodiments. Detailed Implementation

[0012] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0013] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0014] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0015] In a first aspect, embodiments of this application provide a method for cleaning up container images. This method can be applied to, for example... Figure 1 In the application environment shown, processor 110 can communicate with memory 120 via a network to clean up container images in memory 120. Processor 110 can be implemented using a standalone processor or a processor system composed of multiple processors, and memory 120 can be, but is not limited to, static random access memory (SRAM), magnetoresistive random access memory (MRAM), etc.

[0016] The processor 110 may be implemented in at least one of the following hardware forms: programmable logic array (PLA), field-programmable gate array (FPGA), digital signal processor (DSP), application-specific integrated circuit (ASIC), general-purpose processor, or other programmable logic device.

[0017] Of course, the container image cleanup method provided in this application embodiment can also be applied to more scenarios not shown.

[0018] Applying container image cleanup methods Figure 1 Taking processor 110 as an example, in some embodiments, such as Figure 2 As shown, the container image cleanup method includes steps S210 to S240 that can be executed by processor 110. Each step is described in detail below.

[0019] Step S210: Determine the service value parameters of the target container image based on the number of services running on the target container image and the creation time of each service.

[0020] Among them, the service value parameter is positively correlated with the number of services. The further away the current time is from the creation time of the service, the slower the service value parameter grows.

[0021] A container image repository is a system used to store, manage, and distribute container images. Container images in a repository can be pulled into a container orchestration system, such as a Kubernetes cluster, and container entities can be built on the nodes of the cluster, thereby providing services based on the code packaged in the container image. Multiple services can be created from a single container image. The more services a container image corresponds to, the more important the container image can be considered. However, due to the rapid pace of technology iteration, the longer a service has been created, the lower the probability of it being accessed, and the lower the importance of the corresponding container image.

[0022] In some specific embodiments, the service value parameter of the target container image is calculated based on the number of services corresponding to the target container image and the creation time of each service. This can quantify the importance of the target container image. The larger the service value parameter, the higher the importance of the target container image. As the number of services increases, the service value parameter will gradually increase. The longer the service was created, the slower the growth rate of the service value parameter.

[0023] Step S220: Calculate the thermal decay parameters of the target container image based on the shortest idle time of each service corresponding to the target container image.

[0024] The shortest idle time refers to the time difference between the current time and the most recent historical access time of each service. The idle time is positively correlated with the heat decay parameter.

[0025] Since each service runs on its corresponding container image, when a user accesses a service, it can be confirmed that the corresponding container image is in use. Similarly, if none of the services corresponding to a container image are accessed, meaning the services are idle, it can be assumed that the corresponding container image is not in use. Understandably, the importance of container images that have not been used for a long time should be reduced.

[0026] Thermality can be used to reflect the frequency of use of a container image. The higher the thermality value, the higher the frequency of use. The thermal decay parameter can measure the degree of reduction in the frequency of use of a container image.

[0027] In some specific embodiments, by retrieving the access status of each service corresponding to the target container image, the time of the most recent historical access of each service can be determined, that is, the time when the target container image was last used. The time difference between the current time and the most recent historical access time is used as the shortest idle time, which can characterize the idle time of the target container image. Then, the thermal decay parameter of the target container image is calculated by the idle time, and the importance of the target container image is dynamically updated. The longer the idle time, the greater the thermal decay parameter.

[0028] Step S230: Calculate the target score of the target container image based on the service value parameter and the thermal decay parameter.

[0029] Specifically, the importance of the target container image is quantified by the service value parameter, and the importance of the target container image is updated by the thermal decay parameter to obtain the final target score, which reflects the current importance of the target container image.

[0030] Step S240: If the target score of the target container image is less than the preset cleanup threshold, then clean up the target container image.

[0031] Specifically, the rating of each container image is obtained periodically. If the target rating of the target container image is less than the cleanup threshold (0.8), the target container image is deleted from the image repository.

[0032] In some optional embodiments, the cleanup threshold setting can be dynamically adjusted according to the strictness and leniency of the cleanup strategy. When the cleanup threshold is large, it can be applied to scenarios where high-frequency services are created, allowing for timely cleanup of container images to adapt to the service iteration rate. When the cleanup threshold is small, it can be applied to scenarios where long-tail services are protected, ensuring the security of most container images. This application does not impose any limitations on this.

[0033] The container image cleanup method described above calculates service value parameters by using the number of services associated with the container image and the service creation time. This allows for accurate assessment of the service dependencies of the container image and dynamic quantification of its service dependency value. It also calculates thermal decay parameters by using the idle time of services to reflect the actual usage status of the container image, automatically adapting to business fluctuations. Finally, it effectively identifies and cleans up redundant images based on target scores, reducing storage consumption. Furthermore, it protects long-term inactive but critical container images, preventing accidental cleanup and improving the applicability of the container cleanup strategy.

[0034] In some embodiments, such as Figure 3 As shown, when the processor 110 executes step S210, it may also include at least steps S211 to S213.

[0035] Step S211: Determine the initial value contribution parameters of each service according to the creation order of each service.

[0036] Among them, the later a service is created, the lower its initial value contribution parameter.

[0037] The value contribution parameter characterizes the extent to which a service increases the importance of a container image. A higher value contribution parameter indicates a greater increase in the importance of the container image. The value contribution parameter is obtained based on the service's initial value contribution parameter and value contribution decay rate.

[0038] In some specific embodiments, the service value parameter of the target container image increases with each service created that runs on the target container image. The contribution of each service to the service value parameter varies depending on the creation order, meaning that the initial value contribution parameter is different for different services.

[0039] For example, when service 1, which runs on the target container image, is first created, the initial value contribution parameter for service 1 is 6. When service 2 is created, the initial value contribution parameter for service 2 is 5. When service 3 is created, the initial value contribution parameter for service 3 is 4, and so on, gradually decreasing until the initial value contribution parameter decreases to 1. At this point, the initial value contribution parameter for all subsequent services remains 1. In other words, the initial value contribution parameter for each service corresponding to the target container image is A. i =6-i(A) i (Minimum value is 1), where i represents the service creation order.

[0040] Each time a service is created based on a target container image, additional custom code is typically added to differentiate the services. However, as the number of services increases, the available functionality typically decreases, making it less feasible to add custom code to the target container image. Consequently, services created later have a lower initial value contribution parameter compared to those created earlier, and the initial value contribution parameter decreases gradually according to the creation order. However, to ensure that the service value parameter of the target container image increases with each new service, the minimum initial value contribution parameter for a service is set to 1.

[0041] In some optional embodiments, the initial value contribution parameters of different services can also be the same. For example, the initial value contribution parameter of each service is set to 1, that is, the service value parameter of the target container image increases by 1 for each service created. This application does not limit this.

[0042] Step S212: Based on the difference between the current time and the creation time of each service, and the preset value decay coefficient, determine the value contribution decay rate of each service.

[0043] Because technology iterates quickly, services also change rapidly. The earlier a service is created, the lower the probability of it being accessed. In other words, the value contribution of a service after its creation will decay over time. Therefore, based on the service's creation time, the value contribution decay rate can be calculated to reflect the rate of technology iteration.

[0044] For example, t i Let t be the creation time corresponding to the i-th service creation, and t be the current time. Then the service's value contribution decay rate is e^(-α(tt)). i ), where ∂ is a preset value decay coefficient used to control the decay rate of the initial value contribution parameter. The value of ∂ is obtained by fitting the service usage in actual applications, and is usually 0.01±0.002. Where tt i The value is in "days".

[0045] Step S213: Based on the initial value contribution parameters and value contribution decay rate of each service, determine the value contribution parameters of each service, and determine the service value parameters of the target container image according to the sum of the value contribution parameters of each service.

[0046] Specifically, the product A of the initial value contribution parameter and the value contribution decay rate. i ×e^(-α(tt i The value contribution parameters of each service can be used as the sum of the value contribution parameters of each service. Where V(t) is the service value parameter of the target container image. When α=0.01, every day after service creation, The value contribution parameter for each service is A. i ×0.99 means that the final value contribution parameter of each service is 99% of the initial value contribution parameter, which means that the initial value contribution parameter decays by about 1% per day.

[0047] By quantifying the importance of the target container image through its dependency relationship with the service, and controlling the growth rate of the service value parameter using the value contribution decay parameter, the change rate of the service value parameter is made more in line with the actual working conditions, thus improving the intelligence of container image management.

[0048] In some embodiments, step S220 may include step S221: determining the thermal decay parameters of the target container image based on the buffer difference between the shortest idle time and the preset decay start time control factor, as well as the preset decay upper limit control coefficient and decay rate control coefficient.

[0049] Among them, the buffer difference is negatively correlated with the thermal decay parameter.

[0050] Specifically, the thermal decay parameters of the target container image are related to the access frequency of the service. In the period immediately after the service is created, the service is in the startup phase and there are usually no access records. Therefore, in order to ensure that the thermal decay of the target container image remains stable in the short term after the service is created, to adapt to the cold start period of the service and avoid premature decay, a decay start time control factor can be set to control the decay start time. At the same time, the upper limit of thermal decay and the decay rate can be controlled according to the decay upper limit control coefficient and the decay rate control coefficient, respectively.

[0051] For example, the thermal decay function is set as λ(T)=β / (1+e^(-γ(T-(N+δ)))), where λ(T) is the thermal decay parameter, β is the decay upper limit control coefficient (value is 0.2 to 0.3), γ is the decay rate control coefficient (value is 0.15 to 0.25), T is the shortest idle time (unit is "days"), N is the default decay start time (value is 30), δ is the smoothing offset (value is 5 to 10), N and δ together constitute the decay start time control factor, and the unit used is "days".

[0052] The value of β determines the upper limit of the decay of the thermal value of the target container image. When the shortest idle time T approaches infinity, the value of T-(N+δ) is positive, the value of 1+e^(-γ(T-(N+δ))) approaches 1, and λ(T) approaches β (0.2 to 0.3), which indicates that the thermal value of the target container image eventually stabilizes at 20% to 30% of the initial value, which is consistent with the usage state of long-term low-activity container images in actual applications.

[0053] The value of γ determines the rate at which the thermal value of the target container image decays; the larger the γ value, the faster the decay rate.

[0054] The value of N+δ determines the time when the thermal value of the target container image begins to decay. Only when the value of T-(N+δ) is greater than 0 will the value of λ(T) be greater than 0 (rather than approaching 0), indicating that the thermal value of the target container image begins to decay.

[0055] According to the thermal decay function above, the larger the minimum idle time T is, the larger the value of λ(T) is, and the more the thermal value of the target container image decays.

[0056] In some cases, for container images within the decay initiation period (i.e., when T-(N+δ) is less than 0), the value of 1+e^(-γ(T-(N+δ))) approaches infinity, and its thermal decay parameter λ(T) approaches 0 infinitely. In this situation, the thermal value of the container image will not decay. Therefore, the container image can be considered to be in a thermal value protection period within the number of days corresponding to N+δ. Here, N is the default protection period duration set for all container images. Furthermore, different smoothing offsets δ can be set according to the specific characteristics of different container images to adaptively extend the protection period.

[0057] In some optional embodiments, the values ​​of β, γ, N, and δ can be obtained by fitting the thermal value of the container image (i.e., the frequency of use of the container image) in actual applications. This application is only an example and does not limit the scope of the application.

[0058] In some embodiments, before executing step S221, the processor 110 may at least execute step S221-A: determining the decay rate control coefficient based on the target release range of the target container image.

[0059] The larger the target release range, the greater the attenuation rate control coefficient.

[0060] Specifically, when a container image is published to an image repository, its publication scope can be set. For example, a private container image that can only be used within a specific organization can be published to users with specific organizational permissions; a global container image that can be used by all users can be published to all users.

[0061] Generally, private container images are used less frequently than global container images. Therefore, the thermal decay of private container images should be faster. In other words, different decay rate control coefficients can be set for container images with different distribution ranges, so that the thermal decay of container images with smaller distribution ranges is faster, and the thermal decay of container images with larger distribution ranges is slower.

[0062] In some optional embodiments, different attenuation upper limit control coefficients, default attenuation start times, and smoothing offsets may be set for the distribution scope of the container image or other related factors of the container image, and this application does not limit this.

[0063] The usage status of a container image is determined by the thermal decay parameter. If the idle time is always less than the decay start time control factor, the thermal value will hardly decay. The service value parameter of the target container image will always be greater than the cleanup threshold, ensuring that frequently used target container images will not be cleaned up.

[0064] In some embodiments, such as Figure 4As shown, the container image cleanup method also includes steps S410 to S420 that can be executed by the processor 110.

[0065] Step S410: If at least one target service among the services is deleted, determine the service value sacrifice parameter based on the number of services and the creation time of the target service.

[0066] In some specific embodiments, when at least one target service corresponding to the target container image is deleted, the service value parameter of the target container image will decrease. The decrease depends on the service value sacrifice parameter corresponding to the deleted target service, and the service value sacrifice parameter of the target service is related to the creation time of the target service and the original number of services corresponding to the target container image.

[0067] Step S420: Update the service value parameters based on the service value sacrifice parameters.

[0068] Specifically, the difference between the service value parameter and the service value sacrifice parameter is used as the updated service value parameter.

[0069] In some embodiments, such as Figure 5 As shown, when the processor 110 executes step S410, it may also include at least steps S411 to S413.

[0070] Step S411: Determine the initial value sacrifice parameters for the target service based on the number of services.

[0071] Among them, the number of services is negatively correlated with the initial value sacrifice parameter of the target service.

[0072] Specifically, the number of services refers to the number of services corresponding to the target container image before the target service is deleted.

[0073] For example, if the target container image corresponds to services 1, 2, and 3, then according to the information recorded in step S211 above, the initial value contribution parameter A for each service is... i The minimum value is 3, regardless of whether the target service to be deleted is service 1, service 2, or service 3, the initial value sacrifice parameter B corresponding to the target service to be deleted is 3. ii The initial value sacrifice parameter is 3, meaning the initial value sacrifice parameter for the target service is 6-ii, where ii is the number of services corresponding to the target container image before the target service is deleted. The more services there are, the smaller the initial value sacrifice parameter becomes, similar to A. i Corresponding to the value of B ii The minimum value is 1.

[0074] In some optional embodiments, if the initial value contribution parameter of each service is 1, then the initial value sacrifice parameter of each target service is also 1, and this application does not impose any restrictions on this.

[0075] Step S412: Based on the difference between the current time and the creation time of the target service, and the preset value decay coefficient, determine the value sacrifice decay rate of the target service.

[0076] Specifically, corresponding to the content recorded in step S212 above, the value sacrifice decay rate of the target service is e^(-α(tt)). i )), where ∂ is the preset value decay coefficient.

[0077] Step S413: Determine the service value sacrifice parameters based on the initial value sacrifice parameters and the value sacrifice decay rate.

[0078] Specifically, the product B of the initial value sacrifice parameter and the value sacrifice decay rate. ii ×e^(-α(tt i This can be used as a value sacrifice parameter for the target service that is being deleted.

[0079] The service value parameter is updated based on the service value sacrifice parameter, i.e., V'(t) = V(t) - B. ii ×e^(-α(tt i )), where V'(t) is the updated service value parameter.

[0080] The reduction in the number of services corresponding to the target container image reflects a decrease in the importance of the target container image. By updating the service value parameter of the target container image through the service sacrifice parameter of the deleted target services, the service dependency value of the target container image can be dynamically quantified.

[0081] In some embodiments, such as Figure 6 As shown, the container image cleanup method also includes steps S610 to S620 that can be executed by the processor 110.

[0082] Step S610: Determine the initial score of the target container image based on the target image attributes corresponding to the target container image.

[0083] Specifically, based on image attributes, container images can be divided into at least two categories: base images and business images. Base images are container images used by most businesses and are generally of higher importance, while business images are container images used by a small number of special businesses and are of slightly lower importance. Based on this, different initial scores can be set for container images with different attributes. For example, the initial score for base images can be set to 20, and the initial score for business images can be set to 5.

[0084] In some optional embodiments, the container image can be divided into multiple different images according to the image attributes, and different initial scores can be determined for different segments of different images. The above is only an example and this application does not limit it.

[0085] Step S620: Calculate the target score of the target container image based on the initial score, service value parameters, and thermal decay parameters of the target container image.

[0086] Specifically, the target score can be calculated as S(t) = S base +V(t)-∫λ(T)dt, where S(t) is the target score, S base Let V(t) be the initial score for the target container image, V(t) be the service value parameter of the target container image, λ(T) be the thermal decay parameter of the target container image, and the integration interval of λ(T) be the most recent historical access time t for each service corresponding to the target container image. last up to the current time t now ∫λ(T)dt can be understood as the value from the most recent historical access time t last up to the current time t now During the process, the summation of the thermal decay parameters corresponding to the target container image each day represents the cumulative decay amount.

[0087] By quantifying the importance of container images through initial ratings and service value parameters, and by accurately assessing the usage status of container images through thermal decay parameters, precise cleanup of container images can be achieved while reducing the rate of accidental deletion.

[0088] In some embodiments, the container image cleanup method further includes step S710, which can be executed by the processor 110: if the target score of the target container image is greater than a preset protection threshold, the target container image is added to a preset image whitelist and the target score is cleared.

[0089] Container images in the image whitelist cannot be cleaned up.

[0090] Specifically, if the service value parameter of a target container image continuously increases due to the increasing number of services it corresponds to, and the services corresponding to the target container image are frequently used, resulting in low heat decay, and the target score of the target container image exceeds the preset protection threshold, then the importance of the target container image can be considered to meet the protection requirements. Adding the target container image to the image whitelist ensures that the target container image will never be deleted. Furthermore, not calculating the target score for container images in the image whitelist can reduce certain computational overhead.

[0091] The value of the preset protection threshold can be set and dynamically adjusted according to the actual situation, and this application does not impose any restrictions on it.

[0092] In some optional embodiments, important container images that developers believe should not be deleted can be directly recorded in the image whitelist, so that they are not subject to the container image cleanup methods described above, thereby ensuring the security of important container images. This application does not impose any restrictions on this.

[0093] In addition, container images in the image whitelist can be manually screened and cleaned periodically to prevent the image whitelist from overflowing.

[0094] In some embodiments, the container image cleanup method further includes step 610, which can be executed by the processor 110: listening to service creation events and service deletion events in the container orchestration platform, and in response to the service creation events and service deletion events, obtaining rating association data of the target container image, so as to calculate the target rating of the target container image based on the rating association data.

[0095] The target container image's rating-related data includes, at least as mentioned above, the number of services running on the target container image, the creation time of each service, the shortest idle time of each service, and other optional data used to calculate the target rating.

[0096] The above-mentioned container image cleanup method can be used to clean up container images in an image repository, or to clean up container image copies stored locally on a node in a container orchestration system. This application does not limit this.

[0097] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0098] In a second aspect, embodiments of this application provide a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the container image cleanup method provided in any embodiment of the first aspect of this application.

[0099] In some embodiments, the computer device may be a server, and its internal structure diagram may be as follows: Figure 7As shown. The computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores container image data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements the container image cleanup method in any embodiment of this document.

[0100] Those skilled in the art will understand that Figure 7 The structures shown are merely block diagrams of some structures related to the embodiments of this application and do not constitute a limitation on the computer devices on which the embodiments of this application are applied. Specific computer devices may include more or fewer components than those shown in the figures, or combine certain components, or have different component arrangements.

[0101] In a third aspect, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the container image cleanup method provided in any embodiment of the first aspect of this application.

[0102] The computer-readable storage medium may be Figure 7 The computer-readable storage medium in the computer device shown.

[0103] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The aforementioned computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments of this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0104] In a fourth aspect, embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described container image cleanup method embodiments.

[0105] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0106] The foregoing has provided a detailed description of a container image cleaning method, electronic device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of this application.

Claims

1. A method for cleaning up a container image, characterized in that, include: The service value parameter of the target container image is determined based on the number of services running on the target container image and the creation time of each service; wherein, the service value parameter is positively correlated with the number of services, and the further away from the creation time of the service, the slower the service value parameter increases; The thermal decay parameter of the target container image is calculated based on the shortest idle time of each service corresponding to the target container image; the shortest idle time refers to the time difference between the current time and the most recent historical access time of each service; the idle time is positively correlated with the thermal decay parameter; Based on the service value parameter and the thermal decay parameter, the target score of the target container image is calculated. If the target score of the target container image is less than the preset cleanup threshold, then the target container image is cleaned up.

2. The method according to claim 1, characterized in that, The process of determining the service value parameters of the target container image based on the number of services running on the target container image and the creation time of each service includes: The initial value contribution parameter of each service is determined according to the creation order of the services; wherein, the later a service is created, the lower its initial value contribution parameter. Based on the difference between the current time and the creation time of each service, and a preset value decay coefficient, the value contribution decay rate of each service is determined respectively. Based on the initial value contribution parameters and value contribution decay rates of each service, the value contribution parameters of each service are determined, and the service value parameters of the target container image are determined according to the sum of the value contribution parameters of each service.

3. The method according to claim 1, characterized in that, The step of calculating the thermal decay parameters of the target container image based on the shortest idle time of each service corresponding to the target container image includes: The thermal decay parameters of the target container image are determined based on the buffer difference between the shortest idle time and the preset decay start time control factor, as well as the preset decay upper limit control coefficient and decay rate control coefficient; wherein the buffer difference is negatively correlated with the thermal decay parameters.

4. The method according to claim 3, characterized in that, Also includes: Before calculating the thermal decay parameters of the target container image based on the shortest idle time of each service corresponding to the target container image, the decay rate control coefficient is determined based on the target release range of the target container image; wherein, the larger the target release range, the larger the decay rate control coefficient.

5. The method according to any one of claims 1 to 4, characterized in that, Also includes: If at least one of the target services is deleted, a service value sacrifice parameter is determined based on the number of services and the creation time of the target service. The service value parameter is updated based on the service value sacrifice parameter.

6. The method according to claim 5, characterized in that, The process of determining the service value sacrifice parameter based on the number of services and the creation time of the target service includes: Based on the number of services, an initial value sacrifice parameter for the target service is determined; wherein, the number of services is negatively correlated with the initial value sacrifice parameter for the target service. Based on the difference between the current time and the creation time of the target service, and a preset value decay coefficient, the value sacrifice decay rate of the target service is determined. The service value sacrifice parameter is determined based on the initial value sacrifice parameter and the value sacrifice decay rate.

7. The method according to claim 1, characterized in that, If a container image corresponds to preset image attributes, then the target score of the target container image is calculated based on the service value parameter and the heat decay parameter, including: The initial score of the target container image is determined based on the target image attributes corresponding to the target container image. The target score of the target container image is calculated based on the initial score of the target container image, the service value parameter, and the thermal decay parameter.

8. The method according to claim 1, characterized in that, The method further includes: The system listens for service creation and service deletion events in the container orchestration platform. In response to the service creation and service deletion events, it obtains the rating association data of the target container image so as to calculate the target rating of the target container image based on the rating association data.

9. The method according to claim 1, characterized in that, The method further includes: If the target rating of the target container image is greater than the preset protection threshold, the target container image is added to the preset image whitelist and the target rating is cleared.

10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the container image cleanup method as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Container influence measurement method and device based on mirror image dependent network

    CN111694737A

  • Part classification method based on image recognition

    CN111738367A

  • Mirror image clearing method, system and equipment and storage medium

    CN115145693A

  • Root mirror image service quality monitoring method and device, electronic equipment and storage medium

    CN116781565A

  • Log analysis method and device, computer equipment and storage medium

    CN116932500A