首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Harbor私有仓库中如何彻底删除镜像释放存储空间?

Harbor私有仓库中如何彻底删除镜像释放存储空间?

作者头像
全栈程序员站长
发布2021-06-10 16:19:05
发布2021-06-10 16:19:05
3.8K00
代码可运行
举报
运行总次数:0
代码可运行

简介:

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相关服务

代码语言:javascript
代码运行次数:0
运行
复制
$ 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参数,将删除相关的文件和镜像,

代码语言:javascript
代码运行次数:0
运行
复制
$ 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图形界面中删除不需要的镜像

图2:02-停止Harbor服务,执行垃圾回收命令

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/101794.html原文链接:

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档