Python bindings for Podman's RESTful API
Go to file
openshift-merge-bot[bot] 0fd4e55fd5
Merge pull request #581 from inknos/5.6.0
Bump release to 5.6.0
2025-09-05 09:38:28 +00:00
.fmf
.github [skip-ci] Update actions/setup-python action to v6 2025-09-04 09:16:18 +00:00
contrib/examples
docs/source
plans
podman Bump release to 5.6.0 2025-09-04 15:30:35 +02:00
rpm
tests
.gitignore
.packit.yaml
.pre-commit-config.yaml Update Ruff to 0.12.8 2025-09-04 12:18:19 +02:00
.pylintrc
.readthedocs.yaml
CODE-OF-CONDUCT.md
CONTRIBUTING.md
LICENSE
Makefile Bump release to 5.6.0 2025-09-04 15:30:35 +02:00
OWNERS Add Honn1 to OWNERS 2025-09-04 14:26:27 +02:00
README.md
SECURITY.md
gating.yml
mkdocs.yml
podman.svg
pyproject.toml Bump release to 5.6.0 2025-09-04 15:30:35 +02:00
setup.cfg Bump release to 5.6.0 2025-09-04 15:30:35 +02:00
setup.py Lint pep-naming N80 2025-09-04 12:18:20 +02:00
tox.ini Update Ruff to 0.12.8 2025-09-04 12:18:19 +02:00

README.md

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!

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

# Provide a URI path for the libpod service.  In libpod, the URI can be a unix
# domain socket(UDS) or TCP.  The TCP connection has not been implemented in this
# package yet.

uri = "unix:///run/user/1000/podman/podman.sock"

with PodmanClient(base_url=uri) 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() ignores the sparse option and assumes True by default.
        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