A python library for interacting with container images and container image registries
Go to file
whatsacomputertho b692c2be09
Merge pull request #42 from containers/inspect-quick-example
doc(inspect): add inspect to quick example
2025-05-25 21:00:02 -04:00
.github/workflows chore(ci): only trigger release workflow on release 2025-04-28 21:58:02 -04:00
ci fix(ci): set upper bound on twine version 2025-04-28 21:51:42 -04:00
doc/source doc(inspect): add inspect to quick example 2025-05-25 20:57:23 -04:00
examples doc(inspect): add inspect to quick example 2025-05-25 20:57:23 -04:00
image Merge pull request #40 from containers/inspect-doc 2025-05-25 20:33:26 -04:00
tests Merge pull request #34 from containers/inspect 2025-05-25 20:17:47 -04:00
.coveragerc feat(test): test across all supported python versions in ci 2025-04-26 22:36:06 -04:00
.gitignore feat(test): test across all supported python versions in ci 2025-04-26 22:36:06 -04:00
.pre-commit-config.yaml ci(sec): add pip audit and detect secrets in precommit and ci 2025-04-27 10:26:46 -04:00
.secrets.baseline fix(ci): re-generate secrets baseline using latest detect-secrets 2025-04-27 11:12:05 -04:00
CONTRIBUTING.md doc(tools): add contribution documentation 2025-04-27 12:51:52 -04:00
LICENSE Initial commit 2025-04-12 14:29:40 -04:00
Makefile feat(release): develop publish and release make targets 2025-04-27 21:27:25 -04:00
README.md doc(inspect): add inspect to quick example 2025-05-25 20:57:23 -04:00
pyproject.toml chore(ci): only trigger release workflow on release 2025-04-28 21:58:02 -04:00
requirements.txt feat(opensource): open source containerimage-py 2025-04-12 15:28:49 -04:00
tox.ini fix(ci): move pip-audit to sec recipe, fix sec workflow 2025-04-27 10:44:05 -04:00

README.md

containerimage-py

containerimage-py

Test Sec Doc Build

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

Docs: https://containers.github.io/containerimage-py/

Contributing: CONTRIBUTING.md

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.

from image.containerimage import ContainerImage

# Initialize a ContainerImage given a tag reference
my_image = ContainerImage("registry.k8s.io/pause:3.5")

# Display some basic information about the container image
print(
    f"Size of {str(my_image)}: " + \
    my_image.get_size_formatted(auth={}) # 499.91 MB
)
print(
    f"Digest for {str(my_image)}: " + \
    my_image.get_digest(auth={}) # sha256:1ff6c18fbef2045af6b9c16bf034cc421a29027b800e4f9b68ae9b1cb3e9ae07
)

# Inspect the container image image for a more consolidated summary
print(
    f"Inspect for {str(my_image)}:\n" + \
    str(my_image.inspect(auth={})) # Same as skopeo inspect docker://registry.k8s.io/pause:3.5
)

To run this example, simply execute the following from the root of this repository

python3 examples/quick-example.py

Installation

Using Pip

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

pip install containerimage-py

Local Install

  1. Clone this repository
  2. Build the project from source
  3. Locate the .whl (wheel) file in the dist folder
    • It should be named something like so: containerimage_py-0.1.0-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-0.1.0-py3-none-any.whl
    

Build

From the root of this 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. For more on this project's make recipes, see CONTRIBUTING.md.