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 ubuntu:18.04 my.private.registry/my-repo:my-tag
# Copy all tags matching regex
python -m pyregistry 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.4.0.tar.gz
(14.9 kB
view hashes)
Built Distribution
Close
Hashes for aioregistry-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb174105faf6de9a68ff4a6e22ad86a315c9b4a5dcc5991d940ff55c17fc9b26 |
|
MD5 | cbc98713788884511491ccef38224cf1 |
|
BLAKE2b-256 | c7e17f277f7226f4847ec7f0b85163cdd71ef2e634c2cae0ac3ebef2b82e9f05 |