首页 > 其他分享 >docker registry api

docker registry api

时间:2022-11-19 00:55:25浏览次数:67  
标签:xyz manifests v2 api registry https docker

目录

remove registry

https://stackoverflow.com/questions/43666910/remove-docker-repository-on-remote-docker-registry

  1. enable DELETE API:

    1. by config.yml : storage.delete.enabled:true
    2. by env: -e REGISTRY_STORAGE_DELETE_ENABLED=true
  2. get the tag reference via GET /v2//manifests/ (don't forget to have Header Accept: application/vnd.docker.distribution.manifest.v2+json).

in response headers, you have docker-content-digest: sha256:xxx

  1. send DELETE /v2//manifests/sha256:xxx

  2. run garbage collector: bin/registry garbage-collect /etc/docker/registry/config.yml

  3. remove files: rm -r /var/lib/registry/docker/registry/v2/repositories//

registry api


DELETE /v2/<name>/manifests/<reference>

/v2/python/manifests/

/v2/quay.io/coreos/flannel/manifests/

https://docker-hub.one-k.xyz/v2/quay.io/coreos/flannel/tags/list


https://docker-hub.one-k.xyz/v2/openstack.kolla/ubuntu-source-mariadb-clustercheck/manifests/wallaby

https://docker-hub.one-k.xyz/v2/openstack.kolla/ubuntu-source-mariadb-clustercheck/manifests/sha256:d9992cc4f3edd222c9871dac91fbdd3cb4cf47570f0038e4574781df77808eed


c0cd30b832e6

registry api


GET	/v2/<name>/tags/list	Tags	Fetch the tags under the repository identified by name.
GET	/v2/<name>/manifests/<reference>	Manifest	Fetch the manifest identified by name and reference where reference can be a tag or digest. A HEAD request can also be issued to this endpoint to obtain resource information without receiving all data.

和 我们 free_cicd 业务 场景 也没啥 任何 冲突, 这边 主要 针对 gpu 企业 生产, 单子 都是 100w 以上的, 我们 搞好 之后 想 卖 10w 以下的 普通办公 还有 家庭 共享高档 pc

test delete by http

Deleting an Image
An image may be deleted from the registry via its name and reference. A delete may be issued with the following request format:

DELETE /v2//manifests/
For deletes, reference must be a digest or the delete will fail. If the image exists and has been successfully deleted, the following response will be issued:

202 Accepted
Content-Length: None
If the image had already been deleted or did not exist, a 404 Not Found response will be issued instead.

Note When deleting a manifest from a registry version 2.3 or later, the following header must be used when HEAD or GET-ing the manifest to obtain the correct digest to delete:

简单讲 就是 version 2.3 or later,
必须 根据 digest 才可以 删除 image




curl -H "Content-Type: application/json" -X GET   https://docker-hub.one-k.xyz/v2/kolla/ubuntu-binary-chrony/manifests/victoria

curl  --header "Accept: application/vnd.docker.distribution.manifest.v2+json" --head  https://docker-hub.one-k.xyz/v2/kolla/ubuntu-binary-chrony/manifests/victoria


curl  -X DELETE  https://docker-hub.one-k.xyz/v2/kolla/ubuntu-binary-chrony/manifests/sha256:669b590a6a5c31176cd8922d25b78e53875ffa3782f99e1b42b90872c21705da
{"errors":[{"code":"UNSUPPORTED","message":"The operation is unsupported."}]}

# 删除前
du -shm  ./*
57912   ./docker

curl  --header "Accept: application/vnd.docker.distribution.manifest.v2+json"  -X DELETE  https://docker-hub.one-k.xyz/v2/kolla/ubuntu-binary-chrony/manifests/sha256:6fca60ed944301fd97a45ce4b706cddff1f5948d1be56dcc25fe3406169cfed9

curl -I -X DELETE  https://docker-hub.one-k.xyz/v2/kolla/ubuntu-binary-chrony/manifests/669b590a6a5c31176cd8922d25b78e53875ffa3782f99e1b42b90872c21705da


# 回收 registry 空间
#   --delete-untagged=true  必须 加, 否则 registry 很多 空间 都不 释放.
docker exec -it registryssl_register-ssl_1  bin/registry garbage-collect   /etc/docker/registry/config.yml 


# 删除 成功
https://docker-hub.one-k.xyz/v2/kolla/ubuntu-binary-chrony/tags/list
# {
# name: "kolla/ubuntu-binary-chrony",
# tags: null
# }


https://docker-hub.one-k.xyz/v2/kolla/ubuntu-binary-chrony/manifests/victoria
# {
# name: "kolla/ubuntu-binary-chrony",
# tags: [
# "victoria"
# ]
# }

批量 删除 脚本


curl https://docker-hub.one-k.xyz/v2/_catalog?n=1000 2>&1  |  jq  '.repositories'

apt install jq -y


echo `curl https://docker-hub.one-k.xyz/v2/_catalog?n=1000 2>1` | jq '.repositories'  | grep -oE '[a-z0-9./-]+'  | grep -i 'kolla/ubuntu-binary'
kolla/ubuntu-binary-chrony
kolla/ubuntu-binary-cinder-api
...


tag_name='wallaby'
repositories_name='quay.io/openstack.kolla'

function del_registry_img(){
    img_name=${1}

    ref_sha=$(curl  --header "Accept: application/vnd.docker.distribution.manifest.v2+json" --head  https://docker-hub.one-k.xyz/v2/${img_name}/manifests/${tag_name} 2>1 | grep -i 'docker-content-digest'  | grep -oE '[a-z0-9:]{20,}' )

    curl  --header "Accept: application/vnd.docker.distribution.manifest.v2+json"  -X DELETE  https://docker-hub.one-k.xyz/v2/${img_name}/manifests/${ref_sha}
}

for img_name in $( echo `curl https://docker-hub.one-k.xyz/v2/_catalog?n=1000 2>1` | jq '.repositories'  | grep -oE '[a-z0-9./-]+'  | grep -i ${repositories_name} )
do
    del_registry_img  ${img_name}  &
done


# 回收垃圾前
du -shm  ./*
56284   ./docker

# 回收 registry 空间
#   --delete-untagged=true  必须 加, 否则 registry 很多 空间 都不 释放.
docker exec -it registryssl_register-ssl_1  bin/registry garbage-collect   /etc/docker/registry/config.yml --delete-untagged
du -shm  /free_cicdfs0/k8s_data/registry_ssl/registry/docker/*
53531   ./docker



rm -rf /free_cicdfs0/k8s_data/registry_ssl/registry/docker/registry/v2/repositories/quay.io/

# 定位 大文件
du -sh ./*
2.0K    ./0e77cd93e858cf8b1bc1640c470f3e4ca53f69f25327c16f05b43139e532aa7b
129K    ./0eb1c8b8e410da40903631c89f617970663274212b863e194a676ea927368cd2
18G     ./0ed82ff9ed21be65a3aebc52ed2e19558bb778d5bdd8035fdcd383375901f579

docker exec -it registryssl_register-ssl_1  bin/registry garbage-collect   /etc/docker/registry/config.yml --delete-untagged  | grep -i 0ed82ff9ed21be65a3aebc52ed2e19558bb778d5bdd8035fdcd383375901f579
ceph/ceph-dev: marking blob sha256:0ed82ff9ed21be65a3aebc52ed2e19558bb778d5bdd8035fdcd383375901f579


du -d 3 -h ./* | sort -sh  | tail
487M    ./ec
502M    ./ca
1.1G    ./38/3853fdf1e4493f023b9cf5b40e2f825ce112771fb29639c16bf6839d9bdf1fd4
1.1G    ./38
1.3G    ./5a/5a16766e855c48ae4e8b8e459ca95ab6adbc62ca7c66d2bac6e73947fe153cbb
1.3G    ./5a
16G     ./8c/8c435ab66a267e54b6349bcfd8ca7259bff7735e1ac8c8abc06c11617e11ef2a
16G     ./8c
18G     ./0e/0ed82ff9ed21be65a3aebc52ed2e19558bb778d5bdd8035fdcd383375901f579
18G     ./0e

docker exec -it registryssl_register-ssl_1  bin/registry garbage-collect   /etc/docker/registry/config.yml --delete-untagged  | grep -iE '8c435ab66a267e54b6349bcfd8ca7259bff7735e1ac8c8abc06c11617e11ef2a|0ed82ff9ed21be65a3aebc52ed2e19558bb778d5bdd8035fdcd383375901f579'
ceph/ceph-build: marking blob sha256:8c435ab66a267e54b6349bcfd8ca7259bff7735e1ac8c8abc06c11617e11ef2a
ceph/ceph-dev: marking blob sha256:0ed82ff9ed21be65a3aebc52ed2e19558bb778d5bdd8035fdcd383375901f579

linux 查找命令

linux 使用ctrl+r进行搜索输入过的命令


https://docker-hub.one-k.xyz/v2/_catalog?n=1000

https://docker-hub.one-k.xyz/v2/quay.io/openstack.kolla/ubuntu-source-cinder-api/tags/list


docker registry  clean repositories


欢迎大家一起交流呀
qq群:3638803451
vx:wxid_sgdelhiwombj12

标签:xyz,manifests,v2,api,registry,https,docker
From: https://www.cnblogs.com/ltgybyb/p/16905326.html

相关文章

  • https_registry
    目录下载证书生成自己的证书生成ca证书Useself-signedcertificates下载证书mkdircertcdcertcurl-uadmin:brysjhhrhL356126155165352237656123165615-o......
  • 通过docker部署grafana和mysql
    阅读本文需要一定的Linux,Docker与MySQL知识,例如:会启动容器,进入容器;会创建表,会使用INSERT语句,会使用SELECT语句...1.简介2.网络设置-2.1docker网络......
  • Selenium3自动化测试实战--第4章 WebDriver API 2--显示等待和隐式等待
    4.7设置元素等待分显式等待和隐式等待4.7.1显式等待是Webdriver等待某个条件成立时则继续执行,否则在达到最大时长时抛出超时异常官网原文:显示等待是selenium客户可......
  • 不背锅运维:解读docker容器网络
    docker的网络模型如下图:[root@test-a-docker01 ~]# ifconfigdocker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500        inet 172.17.0.1......
  • RESTful API规范
    1.url链接一般都采用https协议进行传输http:数据明文传输https:数据加密传输http+ssl2.用api关键字标识接口url:https://api.baidu.comhttps://www.b......
  • 阿里云Aliyun使用docker-compose pull速度慢
    打开开发者镜像加速配置站点https://cr.console.aliyun.com/cn-shenzhen/instances/mirrors加速器加速器地址https://*复制操作文档UbuntuCentOSMacWindows安......
  • Kubernetes集群配置APIServer公网访问
    内容纲要首先打开/etc/kubernetes/pki目录,里面会有很多证书。执行命令查看当前证书允许通过哪些地址访问APIServer:opensslx509-inapiserver.crt-noout-text|gre......
  • 自己制作一个bing每日图片API
    上代码 <?php$str=file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1');//从bing获取数据if(preg_match('/<url>([^<]+)<\/url>/isU'......
  • docker-compose network名称定义
    docker-compose启动的网络名称:1、没有自定义网络名$catdocker-compose.yamlversion:'2'services:zookeeper1:image:zookeepercontainer_name:zookeeper......
  • 【API设计与开发实践】第2篇 Restful API 设计最佳实践的四个重要改进
    RestfulAPI设计最佳实践已经被讨论过多次,其中命名规则有共识也有差异。从函数实现的角度出发,基于简单、明确的原则,在考虑对接RPCAPI的情况下,可以发现一些冲突和理解上......