harbor仓库垃圾太多 导致磁盘满了,解决过程。

今天服务器发布版本时,发布不上去,查看仓库harbor存储的机器磁盘满了,各种日志清理后,收效甚微。

 

 

经查,发现在 /data/registry/ 目录就占了23G。

[root@bdg v2]# pwd
/data/registry/docker/registry
[root@bdg docker]# ls
registry
[root@bdg docker]# du -sh *
23G     registry

 

 

解决步骤:

1、进入harbor的安装目录

cd /usr/local/harbor/

2、停止harbor服务:目的就是怕在清理过程中有人上传镜像,导致镜像损坏

docker-compose stop

3、查看harbor的待删除的有哪些

docker run -it --name gc --rm --volumes-from registry vmware/registry-photon:v2.6.2-v1.5.0 garbage-collect --dry-run /etc/registry/config.yml

执行过程会安装个服务,需要点时间。。

结果

会看到类似如下信息,都是可删除的镜像:
blob eligible for deletion: sha256:b4ce483b413e6ee4ce469599aa0a1d5420a44b43f26c455fd8786e185c3307c3
blob eligible for deletion: sha256:49874ef75948b7f1cbba32950f3ba7970506e3ec8e35d34a88b1b95174d5ea15
blob eligible for deletion: sha256:67961d11fbfe1ccaa141d7cab80a5c1bbaeba5064a4c13d6e56b85d5fca0987e
blob eligible for deletion: sha256:91aaf359d0bffaa7b1b4467667838b8f4edc5d44aba765b15f4cfb58936d15e3

 

4、既然有垃圾,那么删除,垃圾回收

docker run -it --name gc --rm --volumes-from registry vmware/registry-photon:v2.6.2-v1.5.0 garbage-collect /etc/registry/config.yml

会看到类似这样的执行结果:

INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/a7/a7e856df0c0b8f0e81c682cf8cc336d6a8f716cd9d69ec79c04a73bdc070e363  go.version=go1.7.3 instance.id=ee03db5d-8abd-44d3-8a4c-3ec11510ab92 service=registry
blob eligible for deletion: sha256:fc5a5fca06548de02c2d1565f67739b07b91c1c18f95a297c90fff218e35d572
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/fc/fc5a5fca06548de02c2d1565f67739b07b91c1c18f95a297c90fff218e35d572  go.version=go1.7.3 instance.id=ee03db5d-8abd-44d3-8a4c-3ec11510ab92 service=registry
blob eligible for deletion: sha256:17763224a74c89b7f18d4207a26767d58b2ce0624ea5afac87357adcecf2d36b
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/17/17763224a74c89b7f18d4207a26767d58b2ce0624ea5afac87357adcecf2d36b  go.version=go1.7.3 instance.id=ee03db5d-8abd-44d3-8a4c-3ec11510ab92 service=registry

5、重启harbor服务。

docker-compose start

执行结果:

[root@bdg harbor]# docker-compose start
Starting log         ... done
Starting registry    ... done
Starting registryctl ... done
Starting postgresql  ... done
Starting portal      ... done
Starting redis       ... done
Starting core        ... done
Starting jobservice  ... done
Starting proxy       ... done

 

6、再次查看删除仓库目录地址存储情况:

[root@bdg docker]# du -sh *
2.3G    registry

 

 

 

 

 

 

鸣谢参考文档:https://www.cnblogs.com/Honeycomb/p/10320188.html

 

posted on 2020-12-15 13:04  陈惟鲜的博客  阅读(4958)  评论(0编辑  收藏  举报

导航