Docker Delete Mirror Problem in Warehouse

  docker, question

The configuration file is mounted to the local host

docker run -d -p 6000:5000 --restart=always --name registry -v `pwd`/config.yml:/etc/docker/registry/config.yml registry:2

Modified configuration file
图片描述

Viewing Mirror Information in Warehouse

curl -X GET http://127.0.0.1:6000/v2/_catalog
 {"repositories":["myfirstimage","myfirstimage_2","myfirstimage_3"]}

Get digest value

curl  -I -X GET http://127.0.0.1:6000/v2/myfirstimage/manifests/latest
 HTTP/1.1 200 OK
 Content-Length: 5559
 Content-Type: application/vnd.docker.distribution.manifest.v1+prettyjws
 Docker-Content-Digest: sha256:3a07b4e06c73b2e3924008270c7f3c3c6e3f70d4dbb814ad8bff2697123ca33c
 Docker-Distribution-Api-Version: registry/2.0
 Etag: "sha256:3a07b4e06c73b2e3924008270c7f3c3c6e3f70d4dbb814ad8bff2697123ca33c"
 X-Content-Type-Options: nosniff
 Date: Sun, 31 Jul 2016 11:09:22 GMT

Delete test

curl  -X DELETE http://127.0.0.1:6000/v2/myfirstimage/manifests/sha256:3a07b4e06c73b2e3924008270c7f3c3c6e3f70d4dbb814ad8bff2697123ca33c
 {"errors":[{"code":"MANIFEST_UNKNOWN","message":"manifest unknown"}]}

Why did the deletion fail

The problem lies in takingdigestThat step. In registry2.3And later versions, in order to prevent deletion by mistake, in takingdigestWhen, must provide a special head:

Accept: application/vnd.docker.distribution.manifest.v2+json

Otherwise, an error will be returneddigest. Therefore, takedigestThe statement for should take the following form:

curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
 -I \
 -X HEAD http://127.0.0.1:6000/v2/myfirstimage/manifests/latest

This is how we got it.digestThat’s right.

Refer to official documents:https://docs.docker.com/regis …