harbor倉庫鏡像的刪除


harbor倉庫鏡像的刪除

剛開始自己摸索了下,直接webui界面刪除后,發現倉庫空間未釋放

上傳之前倉庫空間占用為

上傳之后倉庫空間占用為

在webui界面上刪除鏡像后

查看大小

依舊為286m,到是什么原因呢,通過官方github查看使用文檔,終於找到了解決辦法,那就是在webui刪除鏡像是軟刪除,並不會釋放空間,在

webui界面刪除后必須停止harbor后再進行硬刪除,也就是空間釋放,垃圾回收,下面是官方文檔原文

Deleting repositories

Repository deletion runs in two steps.

First, delete a repository in Harbor's UI. This is soft deletion. You can delete the entire repository or just a tag of it. After the soft deletion, the repository is no longer managed in Harbor, however, the files of the repository still remain in Harbor's storage.

browse projectbrowse project

CAUTION: If both tag A and tag B refer to the same image, after deleting tag A, B will also get deleted. if you enabled content trust, you need to use notary command line tool to delete the tag's signature before you delete an image.

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:

$ docker-compose stop

$ 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.

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

$ docker-compose start

For more information about GC, please see GC.

官方已經說的很明白了,第一個run是只打印出來已刪除鏡像,但不進行空間釋放和垃圾回收,執行下面的一個run,成功釋放空間了。

執行垃圾回收命令 docker run -it --name gc --rm --volumes-from registry vmware/registry:2.6.2-photon garbage-collect  /etc/registry/config.yml 自行參照鏡像名稱修改

釋放過程截圖

啟動harbor

查看空間是否釋放

 

我們的空間回來了

再上傳一次試試?

證明沒問題,可以上傳。

也可以下載

至此,倉庫空間釋放,垃圾回收告一段落

附上官方文檔地址

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

 


免責聲明!

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



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