hcguersoy / cleanreg Goto Github PK
View Code? Open in Web Editor NEWA small tool to clean up Docker Registries (v2).
License: Apache License 2.0
A small tool to clean up Docker Registries (v2).
License: Apache License 2.0
Hi,
the ignore option will not delete a digest if two or more tags are pointing to it.
Is there a way in this case to delete the tag (not the digest) at least? Otherwise the tag will never be deleted and the same problem occurs the next time we execute cleanreg. In the worst case cleanreg can not delete digests anymore, because there are to many digests with two or more tags.
I would implement this. But i do not find any registry api request which seems to delete a tag. Do you know if there is a way to do this?
As far as I understand when we want to delete an image (with all its versions) we need to put the "keepimages" parameter to 0. But it does not work as expected. You can see it easily in the next example (I'm using a local built image to execute it).
$ docker run --rm -it cleanreg -r http://$REGISTRY_IP:5000 -v -n busybox2 --keepimages 1
Check if registry server supports v2...
Registry server supports v2!
==================================================>> 100%
will delete repo busybox2 and keep 1 images.
Skipping because found not enough images which can be deleted.
Aborted by user or nothing to delete.
$ docker run --rm -it cleanreg -r http://$REGISTRY_IP:5000 -v -n busybox2 --keepimages 0
usage: cleanreg.py [-h] [-v] -r REGISTRY [-p] [-q] [-n REPONAME]
[-k KEEPIMAGES] [-f REPOSFILE]
cleanreg.py: error: [-n] and [-k] has to be used together.
cleanreg deletes images which are tagged twice, even if setting --ignore option. Looks like --ignore is only checking for duplicates in the same repository.
Having an image example-a:test-123
and tagging it additionally example-b:test-123
. Both will have the same digest. Running cleanreg for example-b
and deleting the image, it will also delete example-a
, even if --ignore option has been set.
Is there any way to use this for registries using token-based authentication or else is it possible to add a feature where it will use an existing docker registry credential for authentication?
See attached log file.
I assume the cause is the following:
Create images for registry and cleanreg
Using Docker Registry in version 2.5.1. You can define the version by setting the REGISTRYTAG env variable
Sending build context to Docker daemon 3.072kB
Step 1/3 : ARG TAG
Please provide a source image with `from` prior to commit
Sending build context to Docker daemon 3.072kB
Step 1/4 : ARG BASEIMAGE
Please provide a source image with `from` prior to commit
Sending build context to Docker daemon 235.5kB
I have installed docker-ce 17.03.1ce-0ubuntu-xenial
The shorthand for --date
is -s
in 1 place README.md and -d
in another.
I think it would be more obvious to rename the --quiet option to --assume-yes like in "apt" or other similar tools.
In the end --quiet does not even reduce the logs but just assume yes for the user interaction.
I am running docker run --rm -it hcguersoy/cleanreg:v0.7.0 -r https://myregistry -cf -k 5 -i
and get the following error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 267, in _bootstrap
self.run()
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/cleanreg.py", line 534, in get_tags_dates_digests_byrepo
pool.map(funcpart, tags_all)
File "/usr/local/lib/python2.7/multiprocessing/pool.py", line 253, in map
return self.map_async(func, iterable, chunksize).get()
File "/usr/local/lib/python2.7/multiprocessing/pool.py", line 572, in get
raise self._value
KeyError: 'history'
Traceback (most recent call last):
File "/cleanreg.py", line 678, in <module>
args.md_workers, args.cacert)
File "/cleanreg.py", line 583, in get_all_tags_dates_digests
result[repo] = repos_tags_digest[repo]
File "<string>", line 2, in __getitem__
File "/usr/local/lib/python2.7/multiprocessing/managers.py", line 774, in _callmethod
raise convert_to_error(kind, result)
KeyError: u'library/postgres'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.