Skip to main content

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


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

Uploaded Source

Built Distribution

aioregistry-0.3.3-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aioregistry-0.3.3.tar.gz
  • Upload date:
  • Size: 14.5 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

Hashes for aioregistry-0.3.3.tar.gz
Algorithm Hash digest
SHA256 3d392661f9028ca550cf0ba70e47eb52d1be4b6577ab1b40607029a70402d7ab
MD5 49c50c55cdbe14dc159358015fc8ed33
BLAKE2b-256 fe83be618388cf3d89304be4e6b0155ea9f3d3346b21e5fed840eeb57534b8cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aioregistry-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 16.2 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

Hashes for aioregistry-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5dbba689cf911d4b0b9a9502129209b53cc1b92b5fc70c86aceeb92b13dfea4c
MD5 956e1b564e861581b717799f2c684865
BLAKE2b-256 05711e2e711e11378c0fb6ce866f886d4e141dd5a294acf76076f87ae3706095

See more details on using hashes here.

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