Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker - How to delete image from a private registry

There is no good answer yet to "How to delete an image from a private registry" in docker.

Already tried the following:
Can't delete Docker Image from Registry
How to delete images from a private docker registry?
How to "delete" an image from a private Docker Registry?
But none of the above seems to work.

As everyone else, I already tried:

DELETE /v2/orassayag/osr_streamer_nginx/manifests/sha256:051adb935bff30abba811fd64da28a5f3b19a48f07c74b067e3bd61ab91152b5 HTTP/1.1

AND

DELETE /v2/orassayag/osr_streamer_nginx/manifests/051adb935bff30abba811fd64da28a5f3b19a48f07c74b067e3bd61ab91152b5 HTTP/1.1

and get every time:

{"errors":[{"code":"UNSUPPORTED","message":"The operation is unsupported."}]}

Anybody had success with this?

Update:
None of the solutions in the links I gave works, and still get 'unsupported' error.

like image 391
Or Assayag Avatar asked Jan 09 '19 11:01

Or Assayag


People also ask

How do I remove a docker image from a repository?

By running simple command docker images -a or docker images . After that you make sure which image want to remove, to do that executing this simple command docker rmi <your-image-id> . Then you can confirm that image has been removed or not by list all the images and check.

Where does private docker registry store images?

By default the registry container keep the data in /var/lib/registry within the container. You can bind mount a local directory on your host like the example did -v /mnt/registry:/var/lib/registry ; which in this case the data will be kept on your host at /mnt/registry.


1 Answers

This is a python script delete all image in private registry, it work on my private registry.

import requests
for repo in requests.get('https://192.168.2.31:5000/v2/_catalog', verify=False).json()['repositories']:
    headers = requests.get('https://192.168.2.31:5000/v2/%s/manifests/v1' % repo, headers = {'Accept': 'application/vnd.docker.distribution.manifest.v2+json'}, verify=False).headers
    if 'Docker-Content-Digest' in headers:
        requests.delete('https://192.168.2.31:5000/v2/%s/manifests/%s' % (repo, headers['Docker-Content-Digest']), verify=False)
like image 76
wei li Avatar answered Oct 19 '22 21:10

wei li