环境:
笔者的本地自建仓库部署在 Windows 系统上,下文中命令的执行环境与本地自建仓库位于同一台机器上。
启动仓库时指定配置
以笔者为例,这是笔者仓库的启动命令:
docker run -d -p 5001:5000 --restart=always -e REGISTRY_STORAGE_DELETE_ENABLED=true --name=win10-registry registry
参数 | 作用 |
---|---|
-d | 后台运行容器 |
-p 5001:5000 | 把宿主机的 5001 端口映射到仓库容器的 5000 端口 |
–restart=always | 重启 Docker 时自动重启容器 |
-e REGISTRY_STORAGE_DELETE_ENABLED=true | 仓库中的镜像可以被 API 删除 |
–name=win10-registry | 容器名 |
查看本地自建仓库中存储的所有仓库
以笔者为例,执行命令:
curl http://localhost:5001/v2/_catalog
5001
是笔者映射到仓库容器的 Windows 端口
查看本地自建仓库中所有的镜像标签
以笔者为例,执行命令:
curl http://localhost:5001/v2/telephone2020/linux/tags/list
5001
是笔者映射到仓库容器的 Windows 端口
telephone2020/linux
是笔者存储在本地自建仓库中的一个子仓库
删除本地自建仓库
以笔者为例,执行命令:
curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" -I -X HEAD http://localhost:5001/v2/telephone2020/linux/manifests/RE2
5001
是笔者映射到仓库容器的 Windows 端口
telephone2020/linux
是笔者存储在本地自建仓库中的一个子仓库
RE2
是笔者telephone2020/linux
仓库中的一个镜像版本扫描二维码关注公众号,回复: 8595999 查看本文章
命令的输出结果如下:
HTTP/1.1 200 OK
Content-Length: 1363
Content-Type: application/vnd.docker.distribution.manifest.v2+json
Docker-Content-Digest: sha256:b1165286043f2745f45ea637873d61939bff6d9a59f76539d6228abf79f87774
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:b1165286043f2745f45ea637873d61939bff6d9a59f76539d6228abf79f87774"
X-Content-Type-Options: nosniff
Date: Tue, 14 Jan 2020 07:32:55 GMT
记录下结果中 Etag: "sha256:
后的 sha256 值。在笔者的例子中,它是 b1165286043f2745f45ea637873d61939bff6d9a59f76539d6228abf79f87774
。
然后执行命令:
curl -X DELETE http://localhost:5001/v2/telephone2020/linux/manifests/sha256:b1165286043f2745f45ea637873d61939bff6d9a59f76539d6228abf79f87774
5001
是笔者映射到仓库容器的 Windows 端口
telephone2020/linux
是笔者存储在本地自建仓库中的一个子仓库
b1165286043f2745f45ea637873d61939bff6d9a59f76539d6228abf79f87774
是上一步中记录下的特定镜像版本的 sha256 值
删除完毕。