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图形界面中删除不需要的镜像

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

2、数人云CTO肖总微信公号的文章:

图3:老肖说两句截图

图4:数人云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

原文地址:http://blog.51cto.com/10321203/2096294

时间: 2024-08-30 15:47:51

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

部署 harbor`私有仓库

部署 harbor 私有仓库 下载 docker-compose-1.12.0 # wget https://github.com/docker/compose/releases/download/1.12.0/docker-compose-Linux-x86_64 # mv docker-compose-Linux-x86_64 /usr/bin/docker-compose # chmod a+x /usr/bin/docker-compose 下载 harbor-1.1.2 # wget

11.部署 harbor 私有仓库

11.部署 harbor 私有仓库 本文档介绍使用 docker-compose 部署 harbor 私有仓库的步骤,你也可以使用 docker 官方的 registry 镜像部署私有仓库(部署 Docker Registry). 使用的变量 本文档用到的变量定义如下: $ export NODE_IP=10.64.3.7 # 当前部署 harbor 的节点 IP $ 下载文件 从 docker compose 发布页面下载最新的 docker-compose 二进制文件 $ wget http

Docker以https访问Harbor私有仓库(二)

1 说明 前文Centos7搭建Harbor私有仓库(二)中,我们以https方式搭建了Harbor,本篇我们主要配置Docker以https方式访问Harbor私有仓库 2 Docker配置 2.1 Mac系统 2.1.1 配置Docker Mac系统中只需配置Proferences -> Proxies使用System Proxy即可,如下: 2.1.2 登录私服验证 docker login registry.anxminise.cc #登录私服 2.2 Windows系统 待补充 2.3

删除docker私有仓库中的镜像

docker私有仓库v2版本中的镜像,官方不建议删除,但是也提供了删除接口: DELETE /v2/<name>/manifests/<reference> Host: <registry host> Authorization: <scheme> <token> 删除的原理就是把索引删掉,但磁盘上的数据是删不掉的.这是由于各个镜像之间的不同层共用的关系,可能导致删除一个镜像后其余的镜像也无法使用了. 用python实现伪删除,代码如下: #-*

获取docker私有仓库中所有镜像的方法

搭建好docker私有仓库,但是不能查看里面的所有镜像,于是写一小脚本,目的是获取到该仓库中的所有镜像的名字. #-*- coding:utf-8 -*- #!/usr/bin/env python ''' Created on 2016.10.8 @author: an_time @desc: get images name from registry ''' import requests import json import traceback repo_ip = '172.16.2.23

在docker私有仓库如何查看有哪些镜像?

搭建了docker私有仓库,上传了一些镜像,时间长了就会忘了有哪些镜像,在网上查了,有大佬是通过脚本查看的,多厉害! #!/usr/bin/env python#-*- coding:utf-8 -*-#'''#Created on 2016.10.8#@author: an_time#@desc: get images name from registry#''' import requestsimport jsonimport traceback repo_ip = '192.168.220

docker删除私有仓库中的镜像

1.curl -X DELETE docker.qian.cn:5000/v1/repositories/镜像名称/ 2. v1可以参考https://gist.github.com/kwk/c5443f2a1abcf0eb1eaa v2可以参考https://github.com/burnettk/delete-docker-registry-image

Centos7搭建Harbor私有仓库(一)

1 说明 前文Centos7搭建DockerRegistry介绍了DockerRegistry的搭建,但它没有UI页面,因此选择Harbor 以下基于镜像CentOS-7-x86_64-Minimal-1804进行搭建 均已root用户进行操作 2 安装docker和docker-compose 参见Centos7安装DockerCE安装Docker引擎 2.1 安装docker-compose 1.下载docker-compose的最新版本 curl -L "https://github.co

docker 建立私有仓库,24.205为镜像仓库所在主机

一.下载registry #yum install -y python-devel libevent-devel python-pip gcc xz-devel #python-pip install docker-registry 二.在所有docker宿主机上都执行以下操作 #vi /etc/sysconfig/docker 设置other_args='--insecure-registry 192.168.24.205:5000' #service docker restart 三.打开防