ricardobranco777 / clean_registry Goto Github PK
View Code? Open in Web Editor NEWDocker Registry Cleanup
License: MIT License
Docker Registry Cleanup
License: MIT License
Hi there! Thanks for the project. What's a point to set the script's exit code to 1?
exit_status = 0
for image in images:
if not clean_repo(image):
exit_status = 1
if not self.garbage_collect():
exit_status = 1
Or do I use it incorrectly? I suppose that in order to delete an image I must run this script twice:
firstly to remove references using
docker run --rm --volumes-from 46068a8a3483 -v /var/run/docker.sock:/var/run/docker.sock ricardobranco/clean_registry -x 46068a8a3483 <repo>:<tag>
and then to garbage-collect the second time:
docker run --rm --volumes-from 46068a8a3483 -v /var/run/docker.sock:/var/run/docker.sock ricardobranco/clean_registry 46068a8a3483
In both cases I get 1 exit code returned for me. Is it correct?
I'm running in Docker and having this issue. The container exit with a KeyError Exception
.
Docker version 19.03.5, build 633a0ea838
Registry image details
"id": "sha256:708bc6af7e5e539bdb59707bbf1053cc2166622f5e1b17666f0ba5829ca6aaea",
"RepoTags": ["registry:2", "registry:2.7.1", "registry:2.7", "registry:latest"],
"RepoDigests":["registry@sha256:7d081088e4bfd632a88e3f3bcd9e007ef44a796fddfe3261407a3f9f04abe1e7"],
Full Exception Traceback
Traceback (most recent call last):
File "/usr/local/bin/clean_registry.py", line 360, in <module>
main()
File "/usr/local/bin/clean_registry.py", line 353, in main
cleaner = RegistryCleaner(container=args.container_or_volume)
File "/usr/local/bin/clean_registry.py", line 185, in __init__
self.registry_dir = self.get_registry_dir()
File "/usr/local/bin/clean_registry.py", line 243, in get_registry_dir
data = yaml.load(self.get_file(config_yml), Loader=yaml.FullLoader)
File "/usr/local/bin/clean_registry.py", line 222, in get_file
as tar, tar.extractfile(os.path.basename(path)) \
File "/usr/lib/python3.6/tarfile.py", line 2092, in extractfile
return self.extractfile(self._find_link_target(tarinfo))
File "/usr/lib/python3.6/tarfile.py", line 2388, in _find_link_target
raise KeyError("linkname %r not found" % linkname)
KeyError: "linkname '/bin/busybox' not found"
I've set up remote connection to my docker daemon and I'm able to execute commands like:
rancher@rancher1:~$ docker --tlsverify=1 -H=tcp://my_ip:2376 --tlscacert=/home/rancher/certs/ca.pem --tlscert=/home/rancher/certs/cert.pem --tlskey=/home/rancher/certs/key.pem ps
And I see containers on the remote host correctly.
But when I try to clean my registry I get this error:
docker --tlsverify=1 -H=tcp://my_ip:2376 --tlscacert=/home/rancher/certs/ca.pem --tlscert=/home/rancher/certs/cert.pem --tlskey=/home/rancher/certs/key.pem run --rm --volumes-from 46068a8a3483 -e DOCKER_HOST=https://my_ip:2376 -v /home/rancher/certs:/root/.docker ricardobranco/clean_registry 46068a8a3483 repo:tag
ERROR: HTTPSConnectionPool(host='my_ip', port=2376): Max retries exceeded with url: /v1.35/containers/46068a8a3483/json (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certific
Notice that I omit -e DOCKER_TLS_VERIFY=1, because otherwise docker shouts at me with this:
ERROR: Path to a certificate and key files must be provided through the client_config param. TLS configurations should map the Docker CLI client configurations. See https://docs.docker.com/engine/articles/https/ for API details.
How should I specify the remote's address and tls stuff to get it working?
Currently clean_revisions is only called when not specifying a remove operation. Shouldn't it be called when -x (remove) is used?
if you run clean_registry -V you don't get the version but rather the usage because a container or volume isn't found. This works better:
if args.help:
print('usage: ' + usage)
sys.exit(0)
elif args.version:
print(progname + " " + VERSION)
sys.exit(0)
elif not agrs.container_or_volume:
print('usage:" + usage)
sys.exit(1)
I have a local /usr/sbin/registry instance running.. (not inside docker) how do I use this to clean up? I have no container to point it at..
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.