podman pod
PodCLI
create
create(name=None, *, add_hosts=(), cgroup_parent=None, cpus=None, cpuset_cpus=None, devices=(), device_read_bps=(), dns=(), dns_options=(), dns_search=(), exit_policy=None, gidmaps=(), hostname=None, infra=None, infra_command=None, infra_conmon_pidfile=None, infra_image=None, infra_name=None, ip=None, ip6=None, labels={}, label_files=(), mac_address=None, memory=None, networks=(), network_aliases=(), no_hosts=False, pid=None, pod_id_file=None, publish=(), replace=False, restart=None, security_options=(), share=None, shm_size=None, subgidname=None, subuidname=None, sysctl={}, uidmaps=(), userns=None, uts=None, volumes=(), volumes_from=())
Creates a pod, but does not start it.
Start it then with the .start()
method.
PARAMETER | DESCRIPTION |
---|---|
name |
The name to set the pod to. If not specified a name is generated.
TYPE:
|
add_hosts |
Add a custom host-to-IP mapping (format 'host:ip'), which adds a line to /etc/hosts. Conflicts with the no_hosts option.
TYPE:
|
cgroup_parent |
Path to cgroups under which the cgroup for the pod is created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process.
TYPE:
|
cpus |
Set the total number of CPUs delegated to the pod. The default is 0.0 indicating that there is no limit on computation power.
TYPE:
|
cpuset_cpus |
CPUs in which to allow execution.
TYPE:
|
devices |
List of device names to pass from the host to containers in the pod.
TYPE:
|
device_read_bps |
Limit read rate (in bytes per second) from a device (e.g. device_read_bps=/dev/sda:1mb).
TYPE:
|
dns |
Set custom DNS servers in the /etc/resolv.conf file that is shared between all containers in the pod.
TYPE:
|
dns_options |
Set custom DNS options in the /etc/resolv.conf file that is shared between all containers in the pod.
TYPE:
|
dns_search |
Set custom DNS search domains in the /etc/resolv.conf file that is shared between all containers in the pod.
TYPE:
|
exit_policy |
Set the exit policy of the pod when the last container exits. Supported policies are 'continue' (default) and 'stop'.
TYPE:
|
gidmaps |
GID map for the user namespace. Using this flag runs all containers in the pod with user namespace enabled. It conflicts with the --userns and --subgidname flags.
TYPE:
|
hostname |
Set the pod's hostname.
TYPE:
|
infra |
Whether to create an infra container and associate it with the pod. An infra container is a lightweight container used to coordinate the shared kernel namespace of a pod.
TYPE:
|
infra_command |
Specify the command that is run to start the infra container.
TYPE:
|
infra_conmon_pidfile |
Write the pid of the infra container's conmon process to a file.
TYPE:
|
infra_image |
The custom image that is used for the infra container.
TYPE:
|
infra_name |
The name that is used for the pod's infra container.
TYPE:
|
ip |
Specify a static IPv4 address for the pod, for example 10.88.64.128. This option can only be used if the pod is joined to only a single network - i.e., network=network-name is used at most once - and if the pod is not joining another container's network namespace via network=container:id. The address must be within the network's IP address pool (default 10.88.0.0/16).
TYPE:
|
ip6 |
Specify a static IPv6 address for the pod, for example fd46:db93:aa76:ac37::10. This option can only be used if the pod is joined to only a single network (see note on the ip argument). The address must be within the network's IPv6 address pool.
TYPE:
|
labels |
Add metadata labels to a pod.
TYPE:
|
label_files |
Read in a line-delimited file of labels.
TYPE:
|
mac_address |
Pod network interface MAC address (e.g. 92:d0:c6:0a:29:33). This option can only be used if the pod is joined to only a single network (see note on the ip argument).
TYPE:
|
memory |
Memory limit for the pod.
TYPE:
|
networks |
Specify networks to use for the pod.
TYPE:
|
network_aliases |
Add network-scoped aliases for the pod, setting the alias for all networks that the container joins.
TYPE:
|
no_hosts |
Do not create /etc/hosts for the pod. This option conflicts with --add-host.
TYPE:
|
pid |
Set the PID mode for the pod. The default is to create a private PID namespace for the pod.
TYPE:
|
pod_id_file |
Write the pod ID to the specified file.
TYPE:
|
publish |
Publish a container's port, or range of ports, within this pod to the host.
TYPE:
|
replace |
If another pod with the same name already exists, replace and remove it.
TYPE:
|
restart |
Restart policy for containers in the pod.
TYPE:
|
security_options |
Security options (AppArmor or SELinux).
TYPE:
|
share |
Namespaces to share between containers in the pod.
TYPE:
|
shm_size |
Size of /dev/shm.
TYPE:
|
subgidname |
Run the container in a new user namespace using the map with name in the /etc/subgid file.
TYPE:
|
subuidname |
Run the container in a new user namespace using the map with name in the /etc/subuid file.
TYPE:
|
sysctl |
Configure namespaced kernel parameters for all containers in the pod.
TYPE:
|
uidmaps |
Run all containers in the pod in a new user namespace using the supplied UID mapping. This option conflicts with the userns and subuidname options.
TYPE:
|
userns |
Set the user namespace mode for all the containers in a pod.
TYPE:
|
uts |
Set the UTS namespace mode for the pod.
TYPE:
|
volumes |
Specify volumes passed to all containers in the pod.
TYPE:
|
volumes_from |
Mount volumes from the specified container(s).
TYPE:
|
Returns
A `python_on_whales.Pod` object.
exists
exists(pod)
Returns True
if the pod exists. False
otherwise.
It's just calling podman.pod.inspect(...)
and verifies that it doesn't throw
a python_on_whales.exceptions.NoSuchPod
.
Returns
A `bool`
inspect
inspect(x)
Creates a python_on_whales.Pod
object.
Returns
`python_on_whales.Pod`, or `List[python_on_whales.Pod]` if the input
was a list of strings.
Raises
`python_on_whales.exceptions.NoSuchPod` if one of the pods does not exist.
kill
kill(x, /, *, signal=None)
Kill pods.
PARAMETER | DESCRIPTION |
---|---|
x |
One or more pods to kill
TYPE:
|
signal |
The signal to send the pods' containers
TYPE:
|
Raises
`python_on_whales.exceptions.NoSuchPod` if a pod does not exist.
list
list(*, filters={})
List the pods on the host.
PARAMETER | DESCRIPTION |
---|---|
filters |
Filters to apply when listing pods
TYPE:
|
Returns
A `List[python_on_whales.Pod]`
logs
logs(pod, container=None, *, names=False, since=None, tail=None, timestamps=False, until=None, follow=False, stream=False)
Returns the logs of a pod's containers as a string or an iterator.
PARAMETER | DESCRIPTION |
---|---|
pod |
The pod to get the container logs of
TYPE:
|
container |
Filter logs by container
TYPE:
|
names |
Output container names instead of IDs in the logs
TYPE:
|
since |
Use a datetime or timedelta to specify the lower date limit for the logs.
TYPE:
|
tail |
Number of lines to show from the end of the logs (default all)
TYPE:
|
timestamps |
Put timestamps next to lines.
TYPE:
|
until |
Use a datetime or a timedelta to specify the upper date limit for the logs.
TYPE:
|
follow |
If
TYPE:
|
stream |
Similar to the
TYPE:
|
Returns
`str` if `stream=False` (the default), `Iterable[Tuple[str, bytes]]`
if `stream=True`.
Raises
`python_on_whales.exceptions.NoSuchPod` if the container does not exist.
If you are a bit confused about follow
and stream
, here are some use cases.
- If you want to have the logs up to this point as a
str
, don't use those args. - If you want to stream the output in real time, use
follow=True, stream=True
- If you want the logs up to this point, but you don't want to fit all the logs
in memory because they are too big, use
stream=True
.
pause
pause(x)
Pauses one or more pods
PARAMETER | DESCRIPTION |
---|---|
x |
One or more pods to pause
TYPE:
|
Raises
`python_on_whales.exceptions.NoSuchPod` if any pods does not exist.
prune
prune()
Remove pods that are not running.
remove
remove(x, /, *, force=False, ignore=False, time=None)
Remove one or more pods.
PARAMETER | DESCRIPTION |
---|---|
x |
Single pod or list of pods to remove.
TYPE:
|
force |
Force removal of the pods
TYPE:
|
ignore |
Ignore errors when specified pod is missing
TYPE:
|
time |
Seconds to wait for pod stop before killing the containers
TYPE:
|
Raises
`python_on_whales.exceptions.NoSuchPod` if any of the pods do not
exist and `ignore` was not set.
restart
restart(x)
Restarts one or more pods
PARAMETER | DESCRIPTION |
---|---|
x |
One or more pods to restart
TYPE:
|
Raises
`python_on_whales.exceptions.NoSuchPod` if any pods does not exist.
start
start(x)
Starts one or more pods
PARAMETER | DESCRIPTION |
---|---|
x |
One or more pods to start
TYPE:
|
Raises
`python_on_whales.exceptions.NoSuchPod` if any pods does not exist.
stats
stats(x)
Get pods resource usage statistics
The data unit is the byte.
PARAMETER | DESCRIPTION |
---|---|
x |
One or a list of pods
TYPE:
|
Returns
A `List[python_on_whales.PodStats]`.
stop
stop(x, /, *, time=None)
Stops one or more pods
PARAMETER | DESCRIPTION |
---|---|
x |
One or more pods to stop
TYPE:
|
time |
Seconds to wait for pods to stop before killing containers
TYPE:
|
Raises
`python_on_whales.exceptions.NoSuchPod` if any pods does not exist.
top
top(pod)
Get the running processes of a pod
Not yet implemented
unpause
unpause(x)
Unpauses one or more pods
PARAMETER | DESCRIPTION |
---|---|
x |
One or more pods to unpause
TYPE:
|
Raises
`python_on_whales.exceptions.NoSuchPod` if any pod do not exist.