A Python REST client for Docker Registries. Pronounced dee-redge client.
It’s useful for automating image tagging and untagging
Usage
Most people will primarily use the Registry class:
from dreg_client import Registry
registry = Registry.build_with_manual_client("https://registry.example.com/v2/")
namespaces = registry.namespaces() # a sequence of strings
repositories = registry.repositories() # a mapping of repository names to Repository objects
ns_repositories = registry.repositories("testns") # a mapping of repository names to Repository objects,
# but only for those repositories in the "testns" namespace
test_repo = registry.repository("testrepo", "testns") # a Repository object
test_repo = registry.repository("testns/testrepo") # an identical repository object
The Repository class has several methods for interacting with individual repositories:
from dreg_client import Repository, Manifest
assert isinstance(test_repo, Repository)
assert test_repo.name == "testns/testrepo"
tags = test_repo.tags() # a sequence of strings
manifest = test_repo.get_manifest(tags[0]) # a Manifest object
assert isinstance(manifest, Manifest)
test_repo.delete_manifest(manifest.digest) # manifests can only be deleted by digest, not by tag
# At the moment, retrieving and deleting blobs returns a requests Response object directly
get_blob_response = test_repo.get_blob("sha256:ce17d456b9373523c40fe294e8918a10059f63c54edd2c8ead1f3079f7fbb22a")
delete_blob_response = test_repo.delete_blob("sha256:ce17d456b9373523c40fe294e8918a10059f63c54edd2c8ead1f3079f7fbb22a")
However, you’re probably going to want to use the high-level get_image() method, which returns an Image object:
from dreg_client import Image, Platform
test_image = test_repo.get_image(tags[0])
assert isinstance(test_image, Image)
assert test_image.repo == "testns/testrepo"
assert test_image.tag == tags[0]
assert test_image.platforms == {
Platform.from_name("linux/amd64"),
Platform.from_name("linux/arm64"),
Platform.from_name("linux/arm/v7"),
}
platform_image = test_image.get_platform_image(Platform.from_name("linux/amd64"))
History
dreg-client is a fork of a project named docker-registry-client. While it looked good, development has stalled, with approved PRs remaining unmerged. The code design was also hostile to strict type checking. I forked it to make some improvements, add type hints, and to resolve several outstanding problems at the time.
This fork is not a drop-in replacement for docker-registry-client. Major changes from upstream include:
Complete removal of python2 support
Complete removal of support for v1 registries
A re-work of class names
A re-work of the requests integration and registry auth service
More higher-level abstractions, to avoid needing to dive into manifest dictionaries
Alternatives
Metadata
Release files for dreg-client 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dreg-client-1.2.0.tar.gz | 29.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dreg_client-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.2 kB
Release files / dreg-client-1.2.0.tar.gz
| Download URL | dreg-client-1.2.0.tar.gz |
|---|---|
| Size | 29.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81c179eab9846ae4873668b6a68a76579e39a7bcdc325c37a4392c0c83a0f021
|
|
BLAKE2b-256 checksum How to use checksums |
2e77dc0627e4e49b2e93f343b97da3d2b7bae62758df3a767fac1432b690cb78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Release files / dreg_client-1.2.0-py3-none-any.whl
| Download URL | dreg_client-1.2.0-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e7ef54ac7e99da639ef729f576f0064aa06a467057df2080e640b74c5a1dad13
|
|
BLAKE2b-256 checksum How to use checksums |
e333716789d53977284ed8167318371aafe121d40fbb68d473196006dda97a67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for dreg-client 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.