-
Notifications
You must be signed in to change notification settings - Fork 879
Delete images (repository + data) from registry #988
Comments
I don't have an answer but have a similar question. I pushed the busybox image to my private 2.0 registry (distribution).
The API doc says that DELETE should work. So I just substitute above and get
So I think that's your answer but it's not working for me. |
Delete will remove the tag, but not the actual payloads. |
Some people have contributed garbage-collector scripts to do the cleanup. You will find them clicking the "delete" label over here. |
I think the issue here is that I'm getting a method not supported on the DELETE request not that the blobs are sticking around. If you have an example |
@squarism so, you are using the golang registry2. Please head over to https://github.com/docker/distribution and/or irc #docker-distribution TLDR: delete is not supported yet, in design phase: distribution/distribution#210 |
Aaah! And I blogged the url to the distribution repo too! I'm sorry, I knew the difference, I failed to see what issue list I was in. 😭 Thanks for the tldr too. 👍 |
;) |
+1 with my operation and output:
|
I sent the same request with @adolphlwq 's request, and got the same response
updateI got the solution to delete images enable deleteset the environment variable the API to delete image
the
But when I get 'v2/repoName/tags/list', the tag which was been deleted is still exist....... |
Hi, I am very new to Docker. I have tried like this "curl -X DELETE localhost:5000/v1/repositories/jenkins_ora_jdk/tags/latest" but this works for tag deletion and not the image data for that tag. So i had to write my own script to do that Job. Since i am only the one who tested this script please use with your own risk This is how i start registry image To delete an Image with tag : (This will also cleans the data specific to that tag) ./docker_registry_delete_image -d 5000 "jenkins_ora_jdk:latest" To see all the Images with tag : ./docker_registry_delete_image -q 5000 : 5000 is Registry PORT # NOTE1. Registry service must be running2. Volume must be mounted locally ( -v /docker/registry/latest:/tmp )3. This works only in Linux environment4. This should be executed in where docker registry is runningdocker_registry_delete_image.sh.txt Thanks, |
@CodeJuan You must edit registry config.xml with
|
Hi,
Now trying to delete:
After the above steps, we still have an entry in the catalog: Any ideas? |
This repo here is deprecated, and any message here is likely to go unnoticed. |
I finally go teached about storage->delete->true in the configuration https://github.com/docker/distribution/blob/master/docs/configuration.md and implemented it. Still, while fetching the digest https://github.com/EugenMayer/docker_registry_cli/blob/master/DockerRegistryRequest.rb#L92 getting a string like sha256:XXXX Using this to feed into delete https://github.com/EugenMayer/docker_registry_cli/blob/master/DockerRegistryRequest.rb#L83 Using the current latest registry:2 (sha256:20f5d95004b71fe14dbe7468eff33f18ee7fa52502423c5d107d4fb0abb05c1d). Is this a bug / fixed already? |
@EugenMayer I've been messing around with this too. It looks like the digest that you return as a header from: Instead, if you docker pull that image from your registry and grab the Digest it spits out after downloading you should should be able to delete using that with:
If anyone knows of a simple way to get this digest other than pulling the image, please let me know. Once that is deleted, run garbage collection dry run and then garbage collect on your registry to actually delete the data that you have marked for deletion. On the docker host that is running your registry, run: |
as requested i created a new issue #1068, maybe you continue work with me there @jshapiro26 |
ups, used the legacy issue, @jshapiro26 see distribution/distribution#1637 instead |
My approach how to delete image tag from docker registry (tested on registry version 2.4.0): 1) Update registry configuration file (config.yml) and restart registry
2) Get tags list GET ://<registry_host>/v2/<repo_name>/tags/list 3) Get manifest for selected tag GET ://<registry_host>/v2/<repo_name>/manifests/<tag_name> 4) Copy digest hash from response header Docker-Content-Digest: <digest_hash> 5) Delete manifest (soft delete). This request only marks image tag as deleted and doesn't delete files from file system. If you want to delete data from file system, run this step and go to the next step DELETE ://<registry_host>/v2/<repo_name>/manifests/<digest_hash> Note! You must set headers for request - Accept: application/vnd.docker.distribution.manifest.v2+json 6) Delete image data from file system Run command from the host machine: docker exec -it <registry_container_id> bin/registry garbage-collect <path_to_registry_config> Note! Usually, <path_to_registry_config>=/etc/docker/registry/config.yml |
Yes, i already implemented this in my docker_registry_cli: So this works - one of the things i missed was the Accept header: application/vnd.docker.distribution.manifest.v2+json] But other then that, it works quiet butifully Hint: dont forget to run the garbage collector to clean up the space |
There is no API available to trigger the GC so I think it's the only possibility to use |
For, the GC is utterly broken in 2.5 - i would assume the registry being completely useless after more then 2 months - you have to wipe it a redo all images. There are severe issues with blobs, pushed will not work because "the layers are already up to date". Using the GC is completely useless, the only thing actually really kinda works is going to /var/lib/registry/repos.. and delete the folder manually - restart the registry container. |
@lorenzvth7 and @EugenMayer, I ended up writing an interactive script for the process I mentioned above and will share it soon and post back here, maybe it'll be useful for someone. The issue i've had is that my team typically just uses the latest tag. The latest tag then starts bloating and there isn't a good way to clean up old versions of latest. I ended up just parsing the output of the I noticed your comment about the header: |
@jshapiro26 I'm able to get the right sha of my image with tag:latest.
Check in my registry
Hope it helps for your. My issue is the following now: This is going fine:
I use the GC to clean up:
Check (seems good to me):
But now the real issue is repushing:
Everything seems to exist already in the registry (isn't it cleaned up?).
The most of space is taken in /bin/registry
Something I don't understand. |
Thanks for the clarification about sending the header! I'll try that out. It sounds like you likely have an older version of that image that would be untagged now since you've deleted latest. If you remove that image again then ssh to your registry and run The script i'm cleaning up goes through and deletes all old SHAs for a specified repo, leaving the one tagged as latest in-tact. |
I pushed the image only with the latest tag. Than I'm able to delete it correctly but after repushing just the same image with just the same tag it goes wrong. Everything seems to exist, All the folders in When I push another image with the same name and same tag (also latest in this case) it's pushing in a fine way (I build it with Maybe it's all a bit unclear but to resume: |
@jshapiro26 your ruby script suffers from the same defect as @EugenMayer mentioned. When I repush the same image, I get the same message "Image already exists", and when I try to pull it from the repo, I got the error "Error: image ubuntu not found". |
@zoobab What image tag of registry are you using? I am using registry:2.4.1 and have never ran into the issue you're referring to. Also, do you run the garbage collection without --dry-run after you use the script and before pushing again? The script doesn't actually run the garbage collection after all the images and blobs are marked. I solve this by have a cron run the garbage collection from the docker host early in the morning everyday. To clarify what I wrote the script for, it is used to remove all versions of an image that are not tagged "latest". Therefore if you're pushing an image with a tag that's called "6.2" or something like that, those images will be removed in addition to all the untagged versions of "latest" leaving only the image with the latest tag for the repo you're "cleaning". I am unable to replicate what you're seeing @zoobab with this script. I use it daily and have an automated build of new images weekly that push successfully. Can you give me some more details so that I might be able to help? |
@jshapiro26 yes, I clean up after without --dry-run so that the disk siez diminishes (which is my goal here). My docker registry version is 2.5.0. When I repush the image after the garbage cleanup, I have this error "Layer already exists". |
are you pushing a new build of the image with a different sha? The script leaves the image with the latest tag in-tact on the registry. If you are pushing the same image up it will throw the error you're seeing. |
@jshapiro26 no, I am trying to repush an old image that was deleted, which has the same sha. In your case, you are repushing "latest" which has a new sha because it was freshly built. |
@zoobab did you restart the registry after the garbage collection ? |
@eesprit I can confirm a restart of the registry solves the "docker push oldimage" problem! |
I thought maybe purging the upload cache would be the root cause of the "docker push oldimage" problem? Is there a way to purge this cache? I have seen some bits in the config.yml file.
There is no way to purge the cache manually? |
I'm trying to delete following your instructions, but get a 403 Forbidden error. I've set the REGISTRY_STORAGE_DELETE_ENABLED: true in the yaml file that starts up the registry. |
I builded a docker-reg-gc shellscript for that stuff. |
Is there someone who knows what's the best way to delete unused revisions? But in DEV we are retagging an image on the same tag ( |
Look at my script there https://github.com/TranceMaster86/docker-reg-gc |
hi do you see that : https://docs.docker.com/registry/spec/api/#/deleting-an-image |
Ive been using reg (https://github.com/jessfraz/reg/tree/master/vendor) to mark the blobs I want to delete from the registry by doing:
I get the output of:
Then I ran the command in my server where the docker registry container is, to run the garbage collector like:
And I got a lot of output back like:
and at the end I get the recap like this:
So according to the output no images were removed from my registry. I confirmed by running df -h and yes I still using the same amount of disk space. So, I don't know what I'm doing wrong, I've followed all the instructions in the docker documentation about the Garbage Collector I don't know what do to do get space back, please help. |
@messyhead, I also got 403 responses for the DELETE requests. Turns out I was making the requests through the registry-frontend, which silently overwrote the config variable that should have enabled the DELETE HTTP verb. The solution was to speak to the registry API directly instead of through the frontend. (ie. port 5000 instead of 80 or 443.) |
I followed the steps in 224280919 and 224325910. However it ends up deleting all tags for a repository instead of just one. Garbage collection removes some unused layers as expected and the next push with a new set of tags only shows the new tags set, not the ones from earlier. Furthermore, after I push a image with newer tags, they can't be listed. Let me illustrate, please let me know what I'm doing something wrong here.
Now push a new image with some tags. The tags are listed but can't be queried.
|
An addendum to my earlier post, two points:
Anyway it's fine now and I will use 2.5.1 for now |
what kind of b.s. is this again? this is a basic function of any tool. |
@sergey-tkalych How to set up the
if it is gitlab.com? |
@CodeJuan can you help with deleting? |
@tarasinf gitlab.com is managed by gitlab, they have their settings for the registry. To delete an image simply get to the registry tab in your repo and there's a delete icon in the tag. |
This oneliner command may help |
What are the ways to delete the pushed images and repositories from registry?
I guess, Docker does not provide any API to do that operation. Any ways, may be using curl, to delete image data from registry?
The text was updated successfully, but these errors were encountered: