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 aioregistry ubuntu:18.04 my.private.registry/my-repo:my-tag
# Copy all tags matching regex
python -m aioregistry ubuntu 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.6.3.tar.gz
(16.1 kB
view details)
Built Distribution
File details
Details for the file aioregistry-0.6.3.tar.gz
.
File metadata
- Download URL: aioregistry-0.6.3.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c720e4f8b72f6360102a1062ae9cc2d967245538f139f25f13427aae73edc6c |
|
MD5 | bf21cde9ed184338e61abe2d431a3fb7 |
|
BLAKE2b-256 | d5e769fbaf34331aff9ced31bcd1ce2c0dfdb99e4d8427c8ee6acd500587153f |
File details
Details for the file aioregistry-0.6.3-py3-none-any.whl
.
File metadata
- Download URL: aioregistry-0.6.3-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc1b1fe4db080fa7b96d76b437a0b0596d58335457a879ea3143edf9c65bb06d |
|
MD5 | 22c8ca2519a6b2fca9c105470f8be5bb |
|
BLAKE2b-256 | c3cf6a00cb5f40709a58b60906a2589ca0d40c6fdb45cdca701570414ea5ca2a |