Skip to main content

Python library for interacting with container image registries

Project description

AIORegistry

aioregistry 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


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.7.2.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

aioregistry-0.7.2-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file aioregistry-0.7.2.tar.gz.

File metadata

  • Download URL: aioregistry-0.7.2.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for aioregistry-0.7.2.tar.gz
Algorithm Hash digest
SHA256 a206345d27c1458b9ead19df648413a59b1080edd70c5ce2fdec1904b428b356
MD5 380a78b7d24f7d3655c2b41a3b16a2c9
BLAKE2b-256 cf09784be91314445b58d98151b4d2a4176f9c3362483f19c4ccca38b5daee92

See more details on using hashes here.

Provenance

File details

Details for the file aioregistry-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: aioregistry-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for aioregistry-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2845aa06fd927919b6ad276c8491db06834943feebebdc668a04b8eef7fa69cb
MD5 128b8c60dbcf7d271251a206e09fc59b
BLAKE2b-256 dfd6031db0023767067ae0821ea34f4195122457379072571636d46b761d6908

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page