containerimage-py documentation

A python library for interacting with container images and container image registries

Quick example

Here is a quick motivating example for how you might use containerimage-py in your python scripts to fetch basic information about a container image.

 1from image.containerimage import ContainerImage
 2
 3# Initialize a ContainerImage given a tag reference
 4my_image = ContainerImage("registry.k8s.io/pause:3.5")
 5
 6# Display some basic information about the container image
 7print(
 8   f"Size of {str(my_image)}: " + \
 9   my_image.get_size_formatted(auth={}) # 499.91 MB
10)
11print(
12   f"Digest for {str(my_image)}: " + \
13   my_image.get_digest(auth={}) # sha256:1ff6c18fbef2045af6b9c16bf034cc421a29027b800e4f9b68ae9b1cb3e9ae07
14)
15
16# Inspect the container image image for a more consolidated summary
17print(
18   f"Inspect for {str(my_image)}:\n" + \
19   str(my_image.inspect(auth={})) # Same as skopeo inspect docker://registry.k8s.io/pause:3.5
20)

Installation

Using Pip

Run the following command to install the latest version of this package using pip

pip install containerimage-py

Local Install

  1. Clone the source repository

  2. Build the project from source following the build instructions

  3. Locate the .whl (wheel) file in the dist folder. It should be named something like so: containerimage_py-1.0.0b1-py3-none-any.whl

  4. Run the following command from the root of the repository, replacing the name of the .whl file if necessary

pip install dist/containerimage_py-1.0.0b1-py3-none-any.whl

Build

From the root of the source repository, execute

make build

Under the hood, this will execute python3 -m build and produce a .whl (wheel) and .tgz (TAR-GZip archive) file in the dist subdirectory.

Indices and Tables