K8s

docker registry 私有镜像仓库清理

2022-01-15  本文已影响0人  andrewkk
docker run -d -v /opt/registry:/var/lib/registry -e REGISTRY_STORAGE_DELETE_ENABLED=true -p 5000:5000 --restart=always --name registry registry:2.7

1.下载python脚本 需要python环境 尽量py3环境
curl https://raw.githubusercontent.com/burnettk/delete-docker-registry-image/master/delete_docker_registry_image.py | sudo tee /usr/local/bin/delete_docker_registry_image >/dev/null
2.赋脚本执行权限
sudo chmod a+x /usr/local/bin/delete_docker_registry_image
delete_docker_registry_image --help
3.加仓库路径变量  docker inspect registry查看-v的持久化目录尽量用映射宿主机的目录
export REGISTRY_DATA_DIR=/opt/registry/docker/registry/v2
4.清理仓库
delete_docker_registry_image --image openjdk:v2
5.检测磁盘是否清理成功
df -h
curl http://192.168.124.3:5000/v2/_catalog
curl http://192.168.124.3:5000/v2/centos/tags/list
du -sh /opt/registry/docker/registry/v2/*

加delete参数不然调用不了删除


image.png image.png

参考文章:
https://github.com/burnettk/delete-docker-registry-image

上一篇下一篇

猜你喜欢

热点阅读