10.11. Attaching a pod to the container network
Attach containers in pod to the network during the pod creation.
Prerequisites
-
The
container-toolsmeta-package is installed.
Procedure
Create a network named
pod-net:# podman network create pod-net /etc/cni/net.d/pod-net.conflistCreate a pod
web-pod:# podman pod create --net pod-net --name web-podRun a container named
web-containerinside theweb-pod:# podman run -d --pod webt-pod --name=web-container docker.io/library/httpdOptional: Display the pods the containers are associated with:
# podman ps -p CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES POD ID PODNAME b7d6871d018c registry.access.redhat.com/ubi10/pause:latest 9 minutes ago Up 6 minutes ago a8e7360326ba-infra a8e7360326ba web-pod 645835585e24 docker.io/library/httpd:latest httpd-foreground 6 minutes ago Up 6 minutes ago web-container a8e7360326ba web-pod
Verification
Show all networks connected to the container:
# podman ps --format="{{.Networks}}" pod-net