-
-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
command for garbage-collect #77
Comments
Hello, Yes you must execute this on the host (or in the container of your private registry) |
I have an idea for an ENV variable on the Registry container.
This will enable garbage collection ON set to a default of every 24hrs I would edit the code myself but I just cant find it. ;-) |
Sorry, but the registry image is out of the scope of this project. |
Thank you.. In the interim I am running on HOST: Dry Run..
OR - Live..
I will try to make an entrypoint file or see if CMD will run properly at end of service config in compose file.. |
@Joxit , After a delete and garbage collect the orphaned images are deleted but there is a listing in the Registry-UI that remains. When I click on it it shows no images within. Is there a way to remove that orphaned listing from the UI as well? |
No, this is a limit from docker registry, see this #53 (comment) |
Here is a snippit of a Bash script I am using for garbage collection and deletion of the orphaned repo.. get_array()
{
curl --user ${REG_USER} http://${REGISTRY}/v2/_catalog >list
sed -i -- s#repositories##g list;
sed -i -- s#\{##g list;
sed -i -- s#\}##g list;
sed -i -- s#:##g list;
sed -i -- s#\\[##g list;
sed -i -- s#\\]##g list;
sed -i -- s#\"##g list;
sed -i -- s#\"##g list;
sed -i -- s#,#" "#g list;
ARRAY1=$(cat list)
garbage_collect
}
garbage_collect()
{
docker exec ui-as-proxy_registry_1 registry garbage-collect /etc/docker/registry/config.yml &&
del_repo
}
del_repo()
{
for i in ${ARRAY1[@]}; do
curl --user ${REG_USER} http://${REGISTRY}/v2/$i/tags/list | grep null ;
if [ $? -eq 0 ]; then
docker exec -it ui-as-proxy_registry_1 rm -rf /var/lib/registry/docker/registry/v2/repositories/$i
fi
done
} Note: after deleting an image via the Repository UI the repository remains and is empty - orphaned if you will.. Creating a bash script with the snippit of code to iterate through the tags works to garbage collect and delete the orphaned repository via tags found. To test properly I needed to restart the registry and UI containers then push the same image back into the registry container - otherwise the layer still exists for the old image somehow and would not allow me to push the image over. After restart of containers i was then able to push my image back into the registry and the UI would show the image once again... Thank you! I hope this helps others.. //Edited for a fix... |
Thanks for sharing your script. I could not use the get_array() part so i have achieved the same with grep and substituion. I leave it here if anyone want to use this:
|
without curl command, it's possible to check empty folder with a To find all tags folder's without any tags :
Extract only the image name folder with a sed, all before the time (time include) and remove subfolders /_manifests/tags Exec find and remove folders inside the container : After that, perhaps some repositories haven't any images. To find theses repositories : |
hope this help |
hi all |
I have noticed that some problems after deleting and garbage collection are from caching in the browser. Do a full refresh of the page to get updated listings. My process is:
@azadiali: the scripts i have found messed up my registry! I had to recover from backup more than once... |
@Joxit |
Has anyone something really working ? I have tried all examples but what I run against my docker registry, the UI still shows empty repos. |
did you force-reload the page? In my case the json object was cached by the browser. As I proxy the ui via an apache I set the no-cache header and that solved the problem. |
@logopk Yes I did, but my empty repo's are still there. Can you exactly post what and how you run things at this current moment ? |
Apache (tls, proxy) > UI > registry:2.8.2 what do you mean with "exactly"? I'm not happy with the garbage collector. It destroyed my registry more than once. So I usually backup docker volumes and return to the backup if sth. goes wrong. |
@logopk the gabrage collector is not nice at all, I wondered if you used some extra script for it. |
@mrashad10 nice script thanks but it doesn't work if you have registries with / in their name. Anyway I think you could run the cleanup on the host instead of insider the container, then you have a better find. |
To whom it may concern: there is a serious bug/non-feature in the garbage collection with multi arch images. That was causing my delete issues and destroyed registry... distribution/distribution#3178 With this in consideration, deleting in the ui and running garbage-collection on the server fixes my issues. |
Does anyone know why this isn't run automatically everytime an image is deleted? It feels like it should be the default behavior to me? |
Hi @littletuna4, I agree you should ask distribution/distribution |
Hello,
What is the command for the garbage-collect?
Does it execute on the host?
Thank you!
The text was updated successfully, but these errors were encountered: