Skip to content
containersPublic

About

Python bindings for Podman's RESTful API

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

385 stars

Watchers

12 watching

Forks

Latest commit

 

History

1,069 Commits

Folders and files

podman-py

PyPI Latest Version

This python package is a library of bindings to use the RESTful API of Podman. It is currently under development and contributors are welcome!

This repository is hosted under the containers GitHub organization and is not yet a formal member of the Podman Container Tools CNCF project; governance links in the repo follow sibling-project conventions until a future move.

Installation

pip install podman

Documentation: https://podman-py.readthedocs.io/en/latest/

Source Code: https://github.com/containers/podman-py


Dependencies

  • For runtime dependencies, see [dependencies] in pyproject.toml
  • For testing and development dependencies, see [project.optional.dependencies] in pyproject.toml
    • The package is split in [progress_bar], [docs], and [test]

Example usage

"""Demonstrate PodmanClient."""

import json
from podman import PodmanClient

with PodmanClient() as client:
    version = client.version()
    print("Release: ", version["Version"])
    print("Compatible API: ", version["ApiVersion"])
    print("Podman API: ", version["Components"][0]["Details"]["APIVersion"], "\n")

    # get all images
    for image in client.images.list():
        print(image, image.id, "\n")

    # find all containers
    for container in client.containers.list():
        # After a list call you would probably want to reload the container
        # to get the information about the variables such as status.
        # Note that list() is sparse by default; pass sparse=False to attempt
        # an inspection of each container.
        container.reload()
        print(container, container.id, "\n")
        print(container, container.status, "\n")

        # available fields
        print(sorted(container.attrs.keys()))

    print(json.dumps(client.df(), indent=4))

Contributing

See CONTRIBUTING.md

About

Python bindings for Podman's RESTful API

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

385 stars

Watchers

12 watching

Forks

Releases

Packages

Used by

Contributors

Languages