{"id":13441107,"url":"https://github.com/andrey-pohilko/registry-cli","last_synced_at":"2025-03-20T11:35:12.746Z","repository":{"id":43706304,"uuid":"70966860","full_name":"andrey-pohilko/registry-cli","owner":"andrey-pohilko","description":"Scripts for easy manipulation of docker-registry from command line (and from scripts)","archived":false,"fork":false,"pushed_at":"2024-04-09T12:32:22.000Z","size":142,"stargazers_count":884,"open_issues_count":40,"forks_count":208,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-08-01T03:33:02.817Z","etag":null,"topics":["docker-registry","garbage-collection","nexus-repository-manager","registry","registry-cli"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrey-pohilko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-10-15T04:48:51.000Z","updated_at":"2024-07-29T02:18:46.000Z","dependencies_parsed_at":"2023-02-13T20:16:55.170Z","dependency_job_id":"cba2059d-917d-436e-a4db-c219a89ff3da","html_url":"https://github.com/andrey-pohilko/registry-cli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrey-pohilko%2Fregistry-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrey-pohilko%2Fregistry-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrey-pohilko%2Fregistry-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrey-pohilko%2Fregistry-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrey-pohilko","download_url":"https://codeload.github.com/andrey-pohilko/registry-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221752287,"owners_count":16874953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-registry","garbage-collection","nexus-repository-manager","registry","registry-cli"],"created_at":"2024-07-31T03:01:30.010Z","updated_at":"2024-10-28T00:31:49.712Z","avatar_url":"https://github.com/andrey-pohilko.png","language":"Python","funding_links":[],"categories":["HarmonyOS","Python"],"sub_categories":["Windows Manager"],"readme":"[![CircleCI](https://circleci.com/gh/andrey-pohilko/registry-cli/tree/master.svg?style=svg\u0026circle-token=5216bf89763aec24bbcd6d15494ea32ffc53d66d)](https://circleci.com/gh/andrey-pohilko/registry-cli/tree/master)\n\n# registry-cli\nregistry.py is a script for easy manipulation of docker-registry from command line (and from scripts)\n\n## Table of Contents\n\n* [Installation](#installation)\n  * [Docker image](#docker-image)\n  * [Python script](#python-script)\n* [Listing images](#listing-images)\n* [Username and password](#username-and-password)\n* [Deleting images](#deleting-images)\n* [Disable ssl verification](#disable-ssl-verification)\n* [Nexus docker registry](#nexus-docker-registry)\n* [Important notes](#important-notes)\n  * [garbage-collection in docker-registry](#garbage-collection-in-docker-registry)\n  * [enable image deletion in docker-registry](#enable-image-deletion-in-docker-registry)\n* [Contribution](#contribution)\n\n## Installation\n\n### Docker image\n\nYou can download ready-made docker image with the script and all python dependencies pre-installed:\n\n```\n    docker pull anoxis/registry-cli\n```\n\nIn this case, replace `registry.py` with `docker run --rm anoxis/registry-cli`\nin all commands below, e.g.\n```\n    docker run --rm anoxis/registry-cli -r http://example.com:5000\n```\n\nNote: when you use the docker image and registry on the same computer (registry is on localhost), then due to internal network created by docker you have to link to the registry's network and refer registry container by its name, not localhost.\nE.g. your registry container is named \"registry\",\nthen the command to launch registry-cli would be\n```bash\n    docker run --rm --link registry anoxis/registry-cli -r http://registry:5000\n```\n### python script\n\nDownload registry.py and set it as executable\n```\n  chmod 755 registry.py\n```\n\nInstall dependencies:\n```\n  sudo pip install -r requirements-build.txt\n```\n\n## Listing images\n\nThe below command will list all images and all tags in your registry:\n```\n  registry.py -l user:pass -r https://example.com:5000\n```\n\nList all images, tags and layers:\n```\n  registry.py -l user:pass -r https://example.com:5000 --layers\n```\n\nList particular image(s) or image:tag (all tags of ubuntu and alpine in this example)\n```\n  registry.py -l user:pass -r https://example.com:5000 -i ubuntu alpine\n```\n\nSame as above but with layers\n```\n  registry.py -l user:pass -r https://example.com:5000 -i ubuntu alpine --layers\n```\n\n## Username and password\n\n  It is optional, you can omit it in case if you use insecure registry without authentication (up to you,\n  but its really insecure; make sure you protect your entire registry from anyone)\n\n  username and password pair can be provided in the following forms\n```\n  -l username:password\n  -l 'username':'password'\n  -l \"username\":\"password\"\n```\n  Username cannot contain colon (':') (I don't think it will contain ever, but anyway I warned you).\n  Password, in its turn, can contain as many colons as you wish.\n\n\n## Deleting images\n\nKeep only last 10 versions (useful for CI):\nDelete all tags of all images but keep last 10 tags (you can put this command to your build script\nafter building images)\n```\n  registry.py -l user:pass -r https://example.com:5000 --delete\n```\n  If number of tags is less than 10 it will not delete any\n\nYou can change the number of tags to keep, e.g. 5:\n```\n  registry.py -l user:pass -r https://example.com:5000 --delete --num 5\n```\n\nYou may also specify tags to be deleted using a list of regexp based names.\nThe following command would delete all tags containing \"snapshot-\" and beginning with \"stable-\" and a 4 digit number:\n\n```\n  registry.py -l user:pass -r https://example.com:5000 --delete --tags-like \"snapshot-\" \"^stable-[0-9]{4}.*\"\n```\n\nAs one manifest may be referenced by more than one tag, you may add tags, whose manifests should NOT be deleted.\nA tag that would otherwise be deleted, but whose manifest references one of those \"kept\" tags, is spared for deletion.\nIn the following case, all tags beginning with \"snapshot-\" will be deleted, save those whose manifest point to \"stable\" or \"latest\":\n\n```\n  registry.py -l user:pass -r https://example.com:5000 --delete --tags-like \"snapshot-\" --keep-tags \"stable\" \"latest\"\n```\nThe last parameter is also available as regexp option with `--keep-tags-like`.\n\n\nDelete all tags for particular image (e.g. delete all ubuntu tags):\n```\n  registry.py -l user:pass -r https://example.com:5000 -i ubuntu --delete-all\n```\n\nDelete all tags for all images (do you really want to do it?):\n```\n  registry.py -l user:pass -r https://example.com:5000 --delete-all --dry-run\n```\n\nDelete all tags by age in hours for the particular image (e.g. older than 24 hours, with `--keep-tags` and `--keep-tags-like` options, `--dry-run` for safe).\n```\n  registry.py -r https://example.com:5000 -i api-docs-origin/master --dry-run --delete-by-hours 24 --keep-tags c59c02c25f023263fd4b5d43fc1ff653f08b3d4x --keep-tags-like late\n```\n\nNote that deleting by age will not prevent more recent tags from being deleted if there are more than 10 (or specified `--num` value). In order to keep all tags within a designated period, use the `--keep-by-hours` flag:\n```\n  registry.py -r https://example.com:5000 --dry-run --delete --keep-by-hours 72 --keep-tags-like latest\n```\n## Disable ssl verification\n\nIf you are using docker registry with a self signed ssl certificate, you can disable ssl verification:\n```\n  registry.py -l user:pass -r https://example.com:5000 --no-validate-ssl\n```\n\n## Nexus docker registry\n\nAdd `--digest-method` flag\n\n```\nregistry.py -l user:pass -r https://example.com:5000 --digest-method GET\n```\n\n## Important notes:\n\n### garbage-collection in docker-registry\n1. docker registry API does not actually delete tags or images, it marks them for later\ngarbage collection. So, make sure you run something like below\n(or put them in your crontab):\n```\n  cd [path-where-your-docker-compose.yml]\n  docker-compose stop registry\n  docker-compose run --rm \\\n       registry bin/registry garbage-collect --delete-untagged \\\n       /etc/docker/registry/config.yml\n  docker-compose up -d registry\n```\nor (if you are not using docker-compose):\n```\n  docker stop registry:2\n  docker run --rm registry:2 bin/registry garbage-collect --delete-untagged \\\n       /etc/docker/registry/config.yml\n  docker start registry:2\n```\nfor more detail on garbage collection read here:\n   https://docs.docker.com/registry/garbage-collection/\n\n### enable image deletion in docker-registry\nMake sure to enable it by either creating environment variable\n  `REGISTRY_STORAGE_DELETE_ENABLED: \"true\"`\nor adding relevant configuration option to the docker-registry's config.yml.\nFor more on docker-registry configuration, read here:\n  https://docs.docker.com/registry/configuration/\n\nYou may get `Error 405` message from script (`Functionality not supported`) when this option is not enabled.\n\n\n## Contribution\nYou are very welcome to contribute to this script. Of course, when making changes,\nplease include your changes into `test.py` and run tests to check that your changes\ndo not break existing functionality.\n\nFor tests to work, more libraries are needed\n```\n  pip install -r requirements-ci.txt\n```\n\nRunning tests is as simple as\n```\n  python test.py\n```\n\nTest will print few error messages, like so\n```\nTesting started at 9:31 AM ...\n  tag digest not found: 400\nerror 400\n```\nthis is ok, because test simulates invalid inputs also.\n\n# Contact\n\nPlease feel free to contact me at anoxis@gmail.com if you wish to add more functionality\nor want to contribute.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrey-pohilko%2Fregistry-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrey-pohilko%2Fregistry-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrey-pohilko%2Fregistry-cli/lists"}