云上的天涯

导航

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

 

posted on 2017-09-06 13:16  云上的天涯  阅读(2323)  评论(1编辑  收藏  举报