Podman-py provides Python bindings for the Podman RESTful API, enabling programmatic interaction with Podman containers, images, networks, and pods. As of version 5.8.0, it offers a comprehensive client for managing Podman resources. The project is actively maintained with frequent minor releases, typically on a monthly or bi-monthly cadence, introducing new features and bug fixes.
pip install podmanVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `PodmanClient` to connect to a running Podman daemon. By default, it tries to auto-detect the socket. It then prints system information and lists any running containers. This example is designed to work with both rootful and rootless Podman installations, assuming the default socket paths.
Thoroughly test existing code after upgrading to `5.0.0` or higher. Consult the Podman-py GitHub repository's commit history or more detailed documentation (if available) for specific changes related to `5.0.0`.
Set the `PODMAN_HOST` environment variable (e.g., `export PODMAN_HOST=unix:///run/user/1000/podman/podman.sock`) or explicitly pass `base_url` to `PodmanClient(base_url='unix:///path/to/socket')`.
Upgrade to `podman-py` version `5.4.0.1` or newer to resolve module import issues.
Upgrade to `podman-py` version `5.1.0` or newer to ensure correct `X-Registry-auth` header encoding for image registry operations.
Keep your `podman-py` client library and Podman daemon versions relatively aligned. Refer to the `podman-py` documentation or release notes for specific compatibility information if you encounter issues.
Ensure `podman` is installed in your current environment using `pip install podman`. If in a Jupyter notebook, use `%pip install podman`. If using a system like Yocto, verify the recipe correctly installs `python3-podman`.
Verify that the Podman service is running (e.g., `systemctl --user status podman.service` for rootless or `systemctl status podman.service` for rootful). Ensure the `PODMAN_HOST` environment variable is correctly set, or explicitly pass the correct `base_url` (e.g., `unix:///run/user/{uid}/podman/podman.sock` for rootless) to `PodmanClient`. Check file permissions on the socket.Install the missing dependency using `pip install rich`.
Verify the image name is correct and present locally using `podman images`. If the image is missing, pull it first using `client.images.pull('image_name')` before attempting to create or run a container from it.Review the parameters passed to the `podman-py` method that caused the error. Consult the `podman-py` documentation for the specific method to ensure all arguments are correct and in the expected format. Check for common issues like malformed YAML if using a higher-level tool or incorrect resource IDs.