Harbor私有倉庫中如何徹底刪除鏡像釋放存儲空間?


簡介:

Harbor私有倉庫運行一段時間后,倉庫中存有大量鏡像,會占用太多的存儲空間。直接通過Harbor界面刪除相關鏡像,並不會自動刪除存儲中的文件和鏡像。需要停止Harbor服務,執行垃圾回收命令,進行存儲空間清理和回收。

相關資料:

1、Harbor用戶手冊中的相關說明:

Next, delete the actual files of the repository using the registry's garbage collection(GC). Make sure that no one is pushing images or Harbor is not running at all before you perform a GC. If someone were pushing an image while GC is running, there is a risk that the image's layers will be mistakenly deleted which results in a corrupted image. So before running GC, a preferred approach is to stop Harbor first.

Run the below commands on the host which Harbor is deployed on to preview what files/images will be affected:

#要啟用垃圾回收(GC),首先要關閉Harbor服務,然后再執行清理命令

#停止Harbor相關服務

$ docker-compose stop

#使用--dry-run參數運行容器,預覽運行效果,但不刪除任何數據

$ docker run -it --name gc --rm --volumes-from registry vmware/registry:2.6.2-photon garbage-collect --dry-run /etc/registry/config.yml

#NOTE: The above option "--dry-run" will print the progress without removing any data.

Verify the result of the above test, then use the below commands to perform garbage collection and restart Harbor.

#不使用--dry-run參數,將刪除相關的文件和鏡像,

$ docker run -it --name gc --rm --volumes-from registry vmware/registry:2.6.2-photon garbage-collect  /etc/registry/config.yml

#重新啟動Harbor相關服務

$ docker-compose start

圖1:01-先在Harbor UI圖形界面中刪除不需要的鏡像

01-先在Harbor UI圖形界面中刪除不需要的鏡像

圖2:02-停止Harbor服務,執行垃圾回收命令

02-停止Harbor服務,執行垃圾回收命令

2、數人雲CTO肖總微信公號的文章:

圖3:老肖說兩句截圖

03-老肖說兩句截圖

圖4:數人雲CTO肖總-微信公眾號-老肖說兩句

04-數人雲CTO微信公眾號-老肖說兩句

參考鏈接:

Harbor用戶指南

https://github.com/vmware/harbor/blob/master/docs/user_guide.md

刪除容器鏡像倉庫中的容器鏡像到底有多難?

http://mp.weixin.qq.com/s?__biz=MzA4ODgwNTk1NQ==&mid=2649949694&idx=1&sn=eda4513942458714a1eb89aaa25c9954&chksm=882322d2bf54abc4cb4e5c37fe348e2849c14f3d7e2897a0d839a045d8789640a1b99ca26d44&mpshare=1&scene=2&srcid=0226hpbvbowRZphA0jkqkTlq&from=timeline#rd

Garbage collection

https://github.com/docker/docker.github.io/blob/master/registry/garbage-collection.md


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM