How to remove old and unused Docker images

前端 未结 26 1801
北恋
北恋 2020-11-22 11:28

When running Docker for a long time, there are a lot of images in system. How can I remove all unused Docker images at once safety to free up the storage?

In additio

26条回答
  •  梦谈多话
    2020-11-22 12:09

    If you want to remove images pulled X months ago, you can try the below example which remove images created three months ago:

    three_months_old_images=`docker images | grep -vi "" | tr -s ' ' | cut -d" " -f3,4,5,6 | grep "3 months ago" | cut -d" " -f1`
    docker rmi $three_months_old_images
    

提交回复
热议问题