I finally found out how I can delete images from my self hosted remote docker registry. Here is how:
Prerequisites
Make sure, that the docker registry supports deletion of images:
user@host:~$ docker exec -it registry cat /etc/docker/registry/config.yml
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
delete:
enabled: true
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
As you can see this registry allows deletion of images.
HTTP API calls
For the next step one needs the URL of the registry. In the example it is “my.docker.registry”. The image is “goa-systems-example” and the tag to be deleted is “0.0.1”.
The codes starting with GET, HEAD and DELETE are HTTP requests that can be executed in a tool like Postman or can be scripted with PowerShell or Python for batch processing.
These commands worked for me and I take no responsibility for accidental deletion. When in doubt consult the official Docker documentation. Please handle with care!
1. Get repositories
GET https://my.docker.registry/v2/_catalog
returns
{ "repositories": [ "goa-systems-example" ] }
2. Get images
GET https://my.docker.registry/v2/goa-systems-example/tags/list
returns
{ "name": "goa-systems-example", "tags": [ "0.0.1" ] }
3. Get manifests for each tag
This requires special header.
HEAD https://my.docker.registry/v2/goa-systems-example/manifests/0.0.1 Accept: application/vnd.docker.distribution.manifest.v2+json
returns as HTTP header
Docker-Content-Digest: sha256:4b2ac7d3aaa230f4070ff97f4c8bf7fdb6f86a172b2a2621e1aa9806b5e6b01c
4. Delete image with digest
DELETE https://my.docker.registry/v2/goa-systems-example/manifests/sha256:4b2ac7d3aaa230f4070ff97f4c8bf7fdb6f86a172b2a2621e1aa9806b5e6b01c