Delete docker image from dockerhub (v2 api)

In order to delete a docker image from a private dockerhub repository server you need to know the digest which can easyly be determined from the header of a manifest request for a specific image tag.

Get a list of available docker image tags for a certain image (`application/json` response):
$ curl --silent https://dockerhub.example.com/v2/NAME/tags/list

Having a list of image tags to determine the digest:
$ for tag in latest master-621d4bc master 1.0.0 1.0.1; do \
curl --silent --head -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
https://dockerhub.example.com/v2/NAME/manifests/${tag} | \
grep docker-content-digest; done | sort | uniq -c

Do delete a specific docker image use the relevant digest and curl a DELETE request to the dockerhub API:
$ curl --silent -X DELETE https://dockerhub.example.com/v2/NAME/manifests/${digest}