搭建方法见系列博文(二)
本文档中域名与搭建使用的域名不同
仓库域名 docker.wecode123.com
端口 6000
访问方式 https
上传镜像
上传两个版本
docker push docker.wecode123.com:6000/saas_qc/saas_admin:V3
docker push docker.wecode123.com:6000/saas_qc/saas_admin:V5
查看仓库中的所有镜像
# curl https://docker.wecode123.com:6000/v2/_catalog
{"repositories":["saas_qc/saas_admin"]}
查看镜像的tag
# curl https://docker.wecode123.com:6000/v2/saas_qc/saas_admin/tags/list
{"name":"saas_qc/saas_admin","tags":["V3","V5"]}
获取镜像hash值,用于删除镜像
格式
- curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" -I -X GET https://docker.wecode123.com:6000/v2/ 此处除域名外固定
- saas_qc/saas_admin 镜像名称
- manifests 固定不变
- V3 镜像tag
# curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" -I -X GET https://docker.wecode123.com:6000/v2/saas_qc/saas_admin/manifests/V3
HTTP/1.1 200 OK
Content-Length: 4307
Content-Type: application/vnd.docker.distribution.manifest.v2+json
Docker-Content-Digest: sha256:5fc4e01a7f684c7449d25920e88f4c1b9fe81ebc1ad69baf778d0c34caabc9fd # 此字段为镜像hash值
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:5fc4e01a7f684c7449d25920e88f4c1b9fe81ebc1ad69baf778d0c34caabc9fd"
X-Content-Type-Options: nosniff
Date: Tue, 21 Apr 2020 07:09:38 GMT
首先 du 查看镜像所在目录大小,874M
# du -sh *
12K certs
8.0K conf
874M data
删除V3镜像
格式与上面获取hash值大致相同
# curl -I -X DELETE https://docker.wecode123.com:6000/v2/saas_qc/saas_admin/manifests/sha256:5fc4e01a7f684c7449d25920e88f4c1b9fe81ebc1ad69baf778d0c34caabc9fd
HTTP/1.1 202 Accepted
Docker-Distribution-Api-Version: registry/2.0
X-Content-Type-Options: nosniff
Date: Tue, 21 Apr 2020 07:11:09 GMT
Content-Length: 0
再次查看目录大小,并没有变化
因为上面删除的只是名称,实际镜像并未删除,需要清理镜像
# du -sh *
12K certs
8.0K conf
874M data
清理镜像
registry_https 为仓库容器名称
# docker exec registry_https bin/registry garbage-collect /etc/docker/registry/config.yml
再次查看目录大小,已经有了变化
# du -sh *
12K certs
8.0K conf
540K data