Use version
Test version: registry-2.4.1
Image deletion steps
1. Obtain the digest of the image through /v2/< image name >/manifests/< tag >Note that the obtained request header needs to be addedAccept: application/vnd.docker.distribution.manifest.v2+jsonOtherwise, the correct digest cannot be obtained (although a digest can also be obtained, the subsequent deletion operation will fail)The return value that fails without adding that header value is:404{"errors":[{"code":"MANIFEST_UNKNOWN","message":"manifest unknown"}2. Delete the mirrorDELETE /v2/<name>/manifests/<reference>
ps: Because I have an authentication service, I will go to the authentication service to obtain a token before obtaining the digest and delete operations.
Problems that arise when deleting
1. The image deletion is incomplete, only the manifests are deleted. For details, see: https://github.com/docker/distribution/issues/17552. Not configured in the registry configuration file
delete:
enabled:true
See the full question at: http://dockone.io/question/883
3. For possible problems with registry configuration, refer to the introduction of the official website configuration file: https://docs.docker.com/registry/configuration/#delete4. The image cannot be completely deleted, only the tag information and the associated manifest actually obtained through _catlog The repository of the image still exists.But the query tag does not have deleted tag information. (If you want to delete this directory, it is estimated that you can only delete the file directory manually, but this will cause the associated layer to be destroyed)
Official website introduction
Deleting an Image
Byname
和
reference
deleting the mirror. The deleted api is as follows (DELETE method, not post or get):
DELETE /v2/<name>/manifests/<reference>
For deletion, reference必须是镜像的
digest will fail otherwise. If there is a mirror and it is successfully deleted, the following response is returned (response)
202 Accepted
Content-Length: None
The actual test returns (using postman):
Status 202 Accepted
Return value body: (null)
Return value headers:
Content-Length →
0
Content-Type →
text/plain; charset=utf-8
Date →
Thu, 03 Nov 2016 09:16:19 GMT
Docker-Distribution-Api-Version →
registry/2.0
X-Content-Type-Options →
nosniff
If the mirror has been deleted, the response http status is: 404 Not Found
Note that when deleting manifest, the version is 2.3 or higher. When
HEAD
或者
GET方式
obtaining digest, you need to add the following request header to the request header (otherwise the deletion will fail):
Accept: application/vnd.docker.distribution.manifest.v2+json
http://blog.csdn.net/ismr_m/article/details/53023515