GithubHelp home page GithubHelp logo

ricardobranco777 / clean_registry Goto Github PK

View Code? Open in Web Editor NEW
51.0 3.0 10.0 164 KB

Docker Registry Cleanup

License: MIT License

Python 84.45% Dockerfile 0.87% Makefile 1.65% Shell 13.03%
docker-registry docker-registry-cleanup

clean_registry's People

Contributors

dependabot[bot] avatar nvtkaszpir avatar ricardobranco777 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

clean_registry's Issues

Script's exit code 1?

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?

linkname '/bin/busybox' not found

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"

Remote command example

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?

-V doesn't work

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.