Python library for interacting with container image registries
Project description
pyregistry
pyregistry is a Python library and CLI tool for inspecting and copying container image data from and between registries.
This library primarily focuses on being a useful tool for dealing with container image registries. It has very limited support for interpretation of the objects stored within.
Library usage
Find sub-manifest based on platform.
async with AsyncRegistryClient() as client:
manifest_ref = parse_image_name("alpine")
manifest = await client.manifest_download(manifest_ref)
if isinstance(manifest, ManifestListV2S2):
for sub_manifest in manifest.manifests:
if sub_manifest.platform.architecture == "amd64":
manifest_ref.ref = sub_manifest.digest
manifest = await client.manifest_download(manifest_ref)
break
else:
raise Exception("Found no matching platform")
else:
print("Not a manifest list")
Download layers of an image
for layer in manifest.layers:
assert layer.media_type == "application/vnd.docker.image.rootfs.diff.tar.gzip"
blob_ref = RegistryBlobRef(manifest_ref.registry, manifest_ref.repo, layer.digest)
# For example we just download into memory. In practice don't do this.
blob_data = io.BytesIO(
b"".join([chunk async for chunk in client.ref_content_stream(blob_ref)])
)
with tarfile.open(mode="r|*", fileobj=blob_data) as tar:
for tarinfo in tar.getmembers():
print(tarinfo.name)
CLI copy tool
# By default it will pull credentials based on ~/.docker/config.json
python -m pyregistry --src ubuntu:18.04 --dst my.private.registry/my-repo:my-tag
# Copy all tags matching regex
python -m pyregistry --src ubuntu --dst my.private.registry/my-repo --tag-pattern '18\..*'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aioregistry-0.3.1.tar.gz
(14.3 kB
view details)
Built Distribution
File details
Details for the file aioregistry-0.3.1.tar.gz
.
File metadata
- Download URL: aioregistry-0.3.1.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51ffa2d95c7d544d8a5f59571afa7dfd12047106113fceed78d983796d34da33 |
|
MD5 | b465dca1789a35fa8840478e96e8e1d4 |
|
BLAKE2b-256 | 9203afd889e35063492dadcd27f70354ee602894d805aed3b3e5cbc0a54b5fd2 |
File details
Details for the file aioregistry-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: aioregistry-0.3.1-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f502cdae2d7b427e892546957b49c013ad405165417021eeba0040205b4a4de |
|
MD5 | 3dce79ee1a26ce4dd287d0cd6f176828 |
|
BLAKE2b-256 | d4b6e710fa6445115ecf07411faa1a58bd0380f08b796dee6fbe3a1f697ca29c |