Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to automatically clear the none image of Docker

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to automatically remove the none image of Docker". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to automatically remove the none image of Docker".

In docker build or pull, a mirror is often generated, which is called dangling in Docker, and is characterized by the fact that label is none.

A large number of none images will burst the disk, resulting in disk full, unable to create files.

1. The docker image labeled as

The following is a set of none images:

[root@ccg] # docker images

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

Centos6.5 v2 434c6fa14315 9 seconds ago 254.8 MB

819f53017d76 56 minutes ago 254.8 MB

II. Clean-up methods

How do I clear the mirror?

1. Use docker image prune

two。 Use docker rmi

Let's start with the first one:

To delete a mirror using docker prune, we just need to execute:

Docker image prune-f

The second way:

Docker rmi-f `docker images | grep''| awk'{print $3}'`

In addition, we often need to clean up the abnormal exit containers in the system.

Docker rm `docker ps-a | grep Exited | awk'{print $1}'`

III. Configuration automation

Automatic deletion of configuration, configure crontab on the corresponding machine

1. Crontab-e

two。 Add the following directive (remove the image of the none tag and the exception exit container before the wee hours of the morning, respectively)

59 23 * docker rmi-f `docker images | grep''| awk'{print $3}'`

59 23 * docker rm `docker ps-a | grep Exited | awk'{print $1}'

Thank you for your reading, the above is the content of "how to automatically remove the none image of Docker". After the study of this article, I believe you have a deeper understanding of how to automatically remove the none image of Docker, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report