Way to delete the images from Private Docker Registry
Asked Answered
I

4

4

I have a Private Docker Registry set up and i have pushed some images from other machine to this registry. Its a V2 registry. I don't know a novel way to delete the images from repositories since these pushed images doesn't get listed in CLI for "docker images".

Can anyone suggest me the proper way to delete those images from the disk?

Appreciate a lot for answer.

Thanks

Insistency answered 2/5, 2017 at 5:28 Comment(2)
Possible duplicate of Deleting images from a private docker registryGarget
Thanks @ François MaturelInsistency
S
9

I have posted same answer to other question. Maybe it would be useful for you.


I've faced same problem with my registry then i tried the solution listed below from a blog page. It works.

Step 1: Listing catalogs

You can list your catalogs by calling this url:

http://YourPrivateRegistyIP:5000/v2/_catalog

Response will be in the following format:

{
  "repositories": [
    <name>,
    ...
  ]
}

Step 2: Listing tags for related catalog

You can list tags of your catalog by calling this url:

http://YourPrivateRegistyIP:5000/v2/<name>/tags/list

Response will be in the following format:

{
"name": <name>,
"tags": [
    <tag>,
    ...
]

}

Step 3: List manifest value for related tag

You can run this command in docker registry container:

curl -v --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X GET http://localhost:5000/v2/<name>/manifests/<tag> 2>&1 | grep Docker-Content-Digest | awk '{print ($3)}'

Response will be in the following format:

sha256:6de813fb93debd551ea6781e90b02f1f93efab9d882a6cd06bbd96a07188b073

Run the command given below with manifest value:

curl -v --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X DELETE http://127.0.0.1:5000/v2/<name>/manifests/sha256:6de813fb93debd551ea6781e90b02f1f93efab9d882a6cd06bbd96a07188b073

Step 4: Delete marked manifests

Run this command in your docker registy container:

bin/registry garbage-collect  /etc/docker/registry/config.yml  

Here is my config.yml

root@c695814325f4:/etc# 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
Starstudded answered 4/5, 2017 at 15:23 Comment(2)
Thanks . It helped meInsistency
Working for me except change grep Docker-Content-Digest to grep docker-content-digestStringent
M
0

Currently you cannot delete an image from a docker registry without an external tool. The easiest way to do so would be to use this script to do so, keeping in mind that it does require downtime.

Molality answered 2/5, 2017 at 7:8 Comment(1)
How is that "Currently you cannot delete an image...". The first response is about deleteing the image from a v2 registry.Membranophone
C
0

You can do this with dredge-tool, (https://github.com/anthonyoteri/dredge/releases)

dredge my.private.registry:5000 delete myimage mytag
Corry answered 2/10, 2023 at 18:10 Comment(0)
M
0

To free the space occupied by deleted image we need to delete the repository and then run the garbage collector. You need to login to the v2 registry:

docker exec -it [docker_registry_container_id] /bin/sh

Repository is here: /var/lib/registry/docker/registry/v2/repositories.

Delete the one you want and then run GC.

Membranophone answered 12/2 at 15:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.