Podman pods
Don't use the constructor directly. Instead use
from python_on_whales import DockerClient
podman = DockerClient(client_call=["podman"])
my_pod = podman.pod.inspect("my-pod-name")
# or
my_pod = podman.pod.create("my-pod-name")
For type hints, use this
from python_on_whales import Pod
def print_container_names(pod: Pod):
print([ctr.name for ctr in pod.containers])
Attributes
The attributes are the same that you get with the command line:
podman pod inspect ...
If you want to know the exact structure, you can go to the
podman pod inspect
reference page
An example is worth many lines of descriptions.
In [1]: from python_on_whales import DockerClient
In [2]: podman = DockerClient(client_call=["podman"])
In [3]: pod = podman.pod.create("my-pod")
In [4]: def super_print(obj):
...: print(f"type={type(obj)}, value={obj}")
...:
In [5]: super_print(pod.id)
type = <class 'str'>, value = 6dd9d69df0c2fd74beec9c06a87d29f9a76bee4a05686ceda322ea7ffe40c919
In [6]: super_print(pod.name)
type = <class 'str'>, value = my-pod
In [7]: super_print(pod.created)
type = <class 'datetime.datetime'>, value = 2025-01-10 19:27:25.257813+00:00
In [8]: super_print(pod.state)
type = <class 'str'>, value = Created
In [9]: super_print(pod.num_containers)
type = <class 'int'>, value = 1
In [10]: super_print(pod.infra_container_id)
type = <class 'str'>, value = 72e781450377f138d932fd638a9223aa8bc239489db0b42a290952882b35913d
In [11]: super_print(pod.shared_namespaces)
type = <class 'list'>, value = ['uts', 'ipc', 'net']
In [12]: super_print(pod.hostname)
type = <class 'str'>, value =
In [13]: super_print(pod.exit_policy)
type = <class 'str'>, value = continue
Methods
Pod
exists
exists()
Returns True
if the pod exists and False
if not.
See the podman.pod.exists
command for information about the arguments.
kill
kill(*, signal=None)
Kill this pod
See the podman.pod.kill
command for
information about the arguments.
logs
logs(container=None, *, names=False, since=None, tail=None, timestamps=False, until=None, follow=False, stream=False)
Returns the logs of the pod containers
See the podman.pod.logs
command for
information about the arguments.
remove
remove(*, force=False, time=None)
Remove this pod.
See the podman.pod.remove
command for
information about the arguments.
restart
restart()
Restart this pod.
See the podman.pod.restart
command for
information about the arguments.
start
start()
Starts this pod.
See the podman.pod.start
command for
information about the arguments.
stop
stop(*, time=None)
Stops this pod.
See the podman.pod.stop
command for
information about the arguments.
unpause
unpause()
Unpause the pod
See the podman.pod.unpause
command for
information about the arguments.