Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 7. Working with pods
Containers are the smallest unit that you can manage with Podman, Skopeo and Buildah container tools. A Podman pod is a group of one or more containers. The Pod concept was introduced by Kubernetes. Podman pods are similar to the Kubernetes definition. Pods are the smallest compute units that you can create, deploy, and manage in OpenShift or Kubernetes environments. Every Podman pod includes an infra container. This container holds the namespaces associated with the pod and allows Podman to connect other containers to the pod. It allows you to start and stop containers within the pod and the pod will stay running. The default infra container on the registry.access.redhat.com/ubi10/pause
image.
7.1. Creating pods Link kopierenLink in die Zwischenablage kopiert!
You can create a pod with one container.
Prerequisites
-
The
container-tools
meta-package is installed.
Procedure
Create an empty pod:
podman pod create --name mypod
$ podman pod create --name mypod 223df6b390b4ea87a090a4b5207f7b9b003187a6960bd37631ae9bc12c433aff The pod is in the initial state Created.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The pod is in the initial state Created.
Optional: List all pods:
podman pod ps
$ podman pod ps POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID 223df6b390b4 mypod Created Less than a second ago 1 3afdcd93de3e
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Notice that the pod has one container in it.
Optional: List all pods and containers associated with them:
podman ps -a --pod
$ podman ps -a --pod CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES POD 3afdcd93de3e registry.access.redhat.com/ubi10/pause Less than a second ago Created 223df6b390b4-infra 223df6b390b4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can see that the pod ID from
podman ps
command matches the pod ID in thepodman pod ps
command. The default infra container is based on theregistry.access.redhat.com/ubi10/pause
image.Run a container named
myubi
in the existing pod namedmypod
:podman run -dt --name myubi --pod mypod registry.access.redhat.com/ubi10/ubi /bin/bash
$ podman run -dt --name myubi --pod mypod registry.access.redhat.com/ubi10/ubi /bin/bash 5df5c48fea87860cf75822ceab8370548b04c78be9fc156570949013863ccf71
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: List all pods:
podman pod ps
$ podman pod ps POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID 223df6b390b4 mypod Running Less than a second ago 2 3afdcd93de3e
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can see that the pod has two containers in it.
Optional: List all pods and containers associated with them:
podman ps -a --pod
$ podman ps -a --pod CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES POD 5df5c48fea87 registry.access.redhat.com/ubi10/ubi:latest /bin/bash Less than a second ago Up Less than a second ago myubi 223df6b390b4 3afdcd93de3e registry.access.redhat.com/ubi10/pause Less than a second ago Up Less than a second ago 223df6b390b4-infra 223df6b390b4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.2. Displaying pod information Link kopierenLink in die Zwischenablage kopiert!
Learn about how to display pod information.
Prerequisites
-
The
container-tools
meta-package is installed. - The pod has been created. For details, see section Creating pods.
Procedure
Display active processes running in a pod:
To display the running processes of containers in a pod, enter:
podman pod top mypod
$ podman pod top mypod USER PID PPID %CPU ELAPSED TTY TIME COMMAND 0 1 0 0.000 24.077433518s ? 0s /pause root 1 0 0.000 24.078146025s pts/0 0s /bin/bash
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To display a live stream of resource usage stats for containers in one or more pods, enter:
podman pod stats -a --no-stream
$ podman pod stats -a --no-stream ID NAME CPU % MEM USAGE / LIMIT MEM % NET IO BLOCK IO PIDS a9f807ffaacd frosty_hodgkin -- 3.092MB / 16.7GB 0.02% -- / -- -- / -- 2 3b33001239ee sleepy_stallman -- -- / -- -- -- / -- -- / -- --
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To display information describing the pod, enter:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can see information about containers in the pod.
7.3. Stopping pods Link kopierenLink in die Zwischenablage kopiert!
You can stop one or more pods by using the podman pod stop
command.
Prerequisites
-
The
container-tools
meta-package is installed. - The pod has been created. For details, see section Creating pods.
Procedure
Stop the pod
mypod
:podman pod stop mypod
$ podman pod stop mypod
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: List all pods and containers associated with them:
podman ps -a --pod
$ podman ps -a --pod CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES POD ID PODNAME 5df5c48fea87 registry.redhat.io/ubi10/ubi:latest /bin/bash About a minute ago Exited (0) 7 seconds ago myubi 223df6b390b4 mypod 3afdcd93de3e registry.access.redhat.com/10/pause About a minute ago Exited (0) 7 seconds ago 8a4e6527ac9d-infra 223df6b390b4 mypod
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can see that the pod
mypod
and containermyubi
are in "Exited" status.
7.4. Removing pods Link kopierenLink in die Zwischenablage kopiert!
You can remove one or more stopped pods and containers by using the podman pod rm
command.
Prerequisites
-
The
container-tools
meta-package is installed. - The pod has been created. For details, see section Creating pods.
- The pod has been stopped. For details, see section Stopping pods.
Procedure
Remove the pod
mypod
, type:podman pod rm mypod
$ podman pod rm mypod 223df6b390b4ea87a090a4b5207f7b9b003187a6960bd37631ae9bc12c433aff
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that removing the pod automatically removes all containers inside it.
Optional: Check that all containers and pods were removed:
podman ps podman pod ps
$ podman ps $ podman pod ps
Copy to Clipboard Copied! Toggle word wrap Toggle overflow