删除registry镜像数据,以centos为例

注意:curl命令中的 “-u geostack-dib:” 参数为registry账号密码,请自行修改或删除

1、修改/etc/docker/registry/config.yml配置文件并重启registry

storage:
  delete:
    enabled: true

2、获取标签列表

curl -u geostack-dib:[email protected] http://172.16.103.118:5000/v2/centos/tags/list

3、获取镜像摘要digest

curl -u geostack-dib:[email protected] -I -H "Accept: application/vnd.docker.distribution.manifest.v2+json" http://172.16.103.118:5000/v2/centos/manifests/7.6.1810

4、根据digest删除镜像

curl -u geostack-dib:[email protected] -I -X DELETE http://172.16.103.118:5000/v2/centos/manifests/sha256:747b2de199b6197a26eb1a24d69740d25483995842b2d2f75824095e9d1d19eb

5、如果当前镜像的标签全部删除完毕则需要执行此步骤

docker exec registry rm -rf /var/lib/registry/docker/registry/v2/repositories/centos

6、调用registry gc清理无效blobs

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

相关推荐