liveBook · Manning

Docker-py

As explained in Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more

docker-py is a Python client library that provides bindings for the Docker API and compatible container-management APIs.

docker-py is a Python bindings library for the Docker API that can also communicate with Podman's compatibility service. It lets Python programs perform container operations otherwise available through Podman commands. section 9.3 section 9.3.1

Point DockerClient at the Podman socket with an explicit base URL, or set DOCKER_HOST and use docker.from_env(). The latter keeps the socket path outside the script and supports environment-based configuration. section 9.3.1

List images through Podman

Set DOCKER_HOST to unix://$XDG_RUNTIME_DIR/podman/podman.sock, create a client with docker.from_env(), and call client.images.list(all=True). The result lists images available through the Podman service.

Table 9.4 Podman-py vs. docker-py (view table figure)

Support

Podman-py

Docker-py

Podman service

✔

✔

Docker daemon

✘

✔

Supports pods

✔

✘

Advanced Podman features

✔

✘

Compare docker-py and podman-py by Docker daemon support, Podman service support, pod support, and advanced Podman features. section 9.3.3

How Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more covers it

How deep it goes
Explains installation, socket selection, environment configuration, and image listing, but stops short of advanced Podman features.
Examples
Demonstrates installing python-docker, listing images, configuring DockerClient, and discovering the Podman socket through DOCKER_HOST.
What it assumes
Assumes limited Python knowledge and requires access to a Podman service socket.
What you can do after
Apply it via Python to list images and operate containers through a configured Podman compatibility socket.
How it connects
Connects the Docker API, Podman compatibility service, podman-py, Docker Compose, and REST API endpoints.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more. The section links point to the parts of the book it draws on.