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

簡介:git

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

相關資料:docker

一、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.app

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

#要啓用垃圾回收(GC),首先要關閉Harbor服務,而後再執行清理命令ui

#中止Harbor相關服務3d

$ docker-compose stoprest

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

$ 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服務,執行垃圾回收命令

二、數人云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

相關文章
相關標籤/搜索