Difference between revisions of "CentOS 8.x working with podman pods"
(Created page with "<yambe:breadcrumb self="Working with podman pods">CentOS 8.x podman|podman</yambe:breadcrumb> =CentOS 8.x working with podman pods= ==Create pod== Create a new pod with desir...") |
m |
||
Line 1: | Line 1: | ||
[[Main Page|Home]] > [[CentOS]] > [[CentOS 8.x]] > [[CentOS 8.x virtualization|Virtualization]] > [[CentOS 8.x podman|podman]] > [[CentOS 8.x working with podman pods|Working with podman pods]] | |||
==Create pod== | ==Create pod== | ||
Line 89: | Line 88: | ||
[[Main Page|Home]] > [[CentOS]] > [[CentOS 8.x]] > [[CentOS 8.x virtualization|Virtualization]] > [[CentOS 8.x podman|podman]] > [[CentOS 8.x working with podman pods|Working with podman pods]] |
Latest revision as of 03:49, 23 April 2022
Home > CentOS > CentOS 8.x > Virtualization > podman > Working with podman pods
Create pod
Create a new pod with desired name
podman pod create --name pod1
List pods
List pods of current system
podman pod list
List all containers including containers which are member of pods
- To list containers including containers of various pods use:
podman ps --all
Note that all pods start with a default container named infra
- To list containers including pod ID use:
podman ps --all --pod
Run container inside pod
To run container inside pod use:
podman run -dt --pod pod1 centos top
Create a pod and container inside pod with port publish string
To create a pod with exposed port use:
sudo podman pod create -p 8080:80 --name web1 sudo podman run -dt --pod web1 -p 8080 nginx:latest
Note that we need to publish all required ports during pod creation. The list cannot be changed later.
Remove pod with all its containers
To remove pod with all its containers (Stop containers, Remove containers and then remove pod) use:
podman pod rm -f <pod-id>
Refer:
Communication between two containers within same pod
All containers with same pod share same network namespace. Hence communication between two containers can be done via 127.0.0.1 IP or localhost itself.
podman pod create --name pod1 podman run --pod pod1 --name pod1_httpd -dt httpd #Validate container belonging to pod is not member of host bridge podman inspect pod1_httpd | grep -i ip podman run --pod pod1 --name pod1_bash -it centos #Within container bash do following curl http://127.0.0.1/ #<html><body><h1>It works!</h1></body></html> curl http://localhost/ #<html><body><h1>It works!</h1></body></html> cat /etc/hosts #127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 #::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #10.88.0.20 pod1
Here we can communicate with containers within pod and base host via infra container having IP 10.88.0.20 as listed in /etc/hosts IP. We can also see the IP by inspecting the pods infra container using commands such as:
podman pod list podman inspect 6aac71d95792-infra | grep -i ip
where 6aac71d95792 should be replaced with pod ID (not infra ID) of the pod
Home > CentOS > CentOS 8.x > Virtualization > podman > Working with podman pods