Create pods
To share network and storage resources, you can add containers to the pod. Each Podman pod includes an infra container, which manages namespaces and allows other containers to connect, start, and stop, keeping the pod running.
Before you begin
- The
container-toolsmeta-package is installed.
Procedure
-
Create an empty pod:
$ podman pod create --name mypod223df6b390b4ea87a090a4b5207f7b9b003187a6960bd37631ae9bc12c433aff The pod is in the initial state Created.The pod is in the initial state Created.
-
Optional: List all pods:
$ podman pod psPOD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID 223df6b390b4 mypod Created Less than a second ago 1 3afdcd93de3eNotice that the pod has one container in it.
-
Optional: List all pods and containers associated with them:
$ podman ps -a --podCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES POD 3afdcd93de3e registry.access.redhat.com/ubi10/pause Less than a second ago Created 223df6b390b4-infra 223df6b390b4You can see that the pod ID from
podman pscommand matches the pod ID in thepodman pod pscommand. The default infra container is based on theregistry.access.redhat.com/ubi10/pauseimage. -
Run a container named
myubiin the existing pod namedmypod:$ podman run -dt --name myubi --pod mypod registry.access.redhat.com/ubi10/ubi /bin/bash5df5c48fea87860cf75822ceab8370548b04c78be9fc156570949013863ccf71 -
Optional: List all pods:
$ podman pod psPOD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID 223df6b390b4 mypod Running Less than a second ago 2 3afdcd93de3eYou can see that the pod has two containers in it.
-
Optional: List all pods and containers associated with them:
$ podman ps -a --podCONTAINER 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