docker 私有仓库删除镜像

推荐第二种方法 (简单粗暴),第一种凑字数(头晕眼花)

如果需要删除已经上传的镜像,现有两种方法

1.官方推荐版重点内容

1) 更改registry容器内/etc/docker/registry/config.yml文件

storage: delete: enabled: true

2) 找出你想要的镜像名称的tag

$ curl -I -X GET <protocol>://<registry_host>/v2/<镜像名>/tags/list

3) 拿到digest_hash参数

$ curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" -I -X GET https://<仓库地址>/v2/<镜像名>/manifests/<tag>

如:

$ curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" -I -X GET https://10.109.252.221:5000/v2/wordpress/manifests/latest

4) 复制digest_hash

Docker-Content-Digest: <digest_hash>

5) 删除清单

$ curl -I -X DELETE <protocol>://<registry_host>/v2/<repo_name>/manifests/<digest_hash>

如:

$ curl -I -X DELETE https://10.109.252.221:5000/v2/wordpress/manifests/sha256:b3a15ef1a1fffb8066d0f0f6d259dc7f646367c0432e3a90062b6064f874f57c

6) 删除文件系统内的镜像文件,注意2.4版本以上的registry才有此功能

$ docker exec -it <registry_container_id> bin/registry garbage-collect <path_to_registry_config>

如:

$ docker exec registry bin/registry garbage-collect /etc/docker/registry/config.yml

2.简易版(推荐)
1.打开镜像的存储目录,如有-V操作打开挂载目录也可以,删除镜像文件夹

$ docker exec <容器名> rm -rf /var/lib/registry/docker/registry/v2/repositories/<镜像名>

2.执行垃圾回收操作,注意2.4版本以上的registry才有此功能

$ docker exec registry bin/registry garbage-collect /etc/docker/registry/config.yml

原文链接:https://blog.csdn.net/u014756339/article/details/121289329?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168994567316800225523234%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168994567316800225523234&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-14-121289329-null-null.268%5Ev1%5Ekoosearch&utm_term=docker%E3%80%81wordpress%E3%80%81wordpress%E5%BB%BA%E7%AB%99%E3%80%81wordpress%E4%B8%BB%E9%A2%98%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81

© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享