Podman : Create Pods2025/11/12 |
|
Create Pods like Kubernetes. |
|
| [1] | Create a Pod and add a Container to it. |
|
# create a empty pod # -p [bind port] -n [pod name] [root@dlp ~]# podman pod create -p 8081:80 -n test-pod 7c9a783e9ee274e423ddb9083ac624909c4cbbc6c3eceb0d6b0b59f58ca13ff7 # show pods [root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 7c9a783e9ee2 test-pod Created 12 seconds ago 065c093626a2 1 # show details of pod [root@dlp ~]# podman pod inspect test-pod
[
{
"Id": "7c9a783e9ee274e423ddb9083ac624909c4cbbc6c3eceb0d6b0b59f58ca13ff7",
"Name": "test-pod",
"Created": "2025-11-12T09:40:55.050521405+09:00",
"CreateCommand": [
"podman",
"pod",
"create",
"-p",
"8081:80",
"-n",
"test-pod"
],
"ExitPolicy": "continue",
"State": "Created",
"Hostname": "",
"CreateCgroup": true,
"CgroupParent": "machine.slice",
"CgroupPath": "machine.slice/machine-libpod_pod_7c9a783e9ee274e423ddb9083ac624909c4cbbc6c3eceb0d6b0b59f58ca13ff7.slice",
"CreateInfra": true,
"InfraContainerID": "065c093626a2898aac48c1ab98672535c35332ca83acff82b14a05536490c5f6",
"InfraConfig": {
"PortBindings": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8081"
}
]
},
"HostNetwork": false,
"StaticIP": "",
"StaticMAC": "",
"NoManageResolvConf": false,
"DNSServer": null,
"DNSSearch": null,
"DNSOption": null,
"NoManageHostname": false,
"NoManageHosts": false,
"HostAdd": null,
"HostsFile": "",
"Networks": [
"podman"
],
"NetworkOptions": null,
"pid_ns": "private",
"userns": "host",
"uts_ns": "private"
},
"SharedNamespaces": [
"uts",
"ipc",
"net"
],
"NumContainers": 1,
"Containers": [
{
"Id": "065c093626a2898aac48c1ab98672535c35332ca83acff82b14a05536490c5f6",
"Name": "7c9a783e9ee2-infra",
"State": "created"
}
],
"LockNumber": 9
}
]
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/iproute latest 126eb1cb6c14 6 minutes ago 279 MB docker.io/library/root-web latest fdd007dce795 13 minutes ago 346 MB srv.world/fedora-nginx latest 78a532c42789 43 minutes ago 346 MB srv.world/fedora-httpd latest 9681aa9061c7 50 minutes ago 349 MB docker.io/library/mariadb latest 7418b34b3691 30 hours ago 335 MB registry.fedoraproject.org/fedora latest a9005aba99b1 2 days ago 186 MB # run container and add it to pod [root@dlp ~]# podman run -dt --pod test-pod srv.world/fedora-nginx e36a612d224cbcb324672419de6b66e4de86ad5c7867443c908526529e9e5151[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 065c093626a2 About a minute ago Up 15 seconds 0.0.0.0:8081->80/tcp 7c9a783e9ee2-infra e36a612d224c srv.world/fedora-nginx:latest /usr/sbin/nginx -... 15 seconds ago Up 15 seconds 0.0.0.0:8081->80/tcp thirsty_roentgen # verify accesses [root@dlp ~]# curl localhost:8081 Podman Test on Nginx # stop pod [root@dlp ~]# podman pod stop test-pod test-pod # remove pod (removed containers all) [root@dlp ~]# podman pod rm test-pod --force 7c9a783e9ee274e423ddb9083ac624909c4cbbc6c3eceb0d6b0b59f58ca13ff7 |
| [2] | It's possible to create Pod and add Container with one command. |
|
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/iproute latest 126eb1cb6c14 7 minutes ago 279 MB docker.io/library/root-web latest fdd007dce795 15 minutes ago 346 MB srv.world/fedora-nginx latest 78a532c42789 45 minutes ago 346 MB srv.world/fedora-httpd latest 9681aa9061c7 52 minutes ago 349 MB docker.io/library/mariadb latest 7418b34b3691 30 hours ago 335 MB registry.fedoraproject.org/fedora latest a9005aba99b1 2 days ago 186 MB # create a [test-pod2] pod and add [srv.world/fedora-nginx] container [root@dlp ~]# podman run -dt --pod new:test-pod2 -p 80:80 -p 3306:3306 srv.world/fedora-nginx 4497d0dd2ccd77dcba80b8fcf4aa35c7956768ec5bfb059344cb8837c136234c[root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 042eee2a4d8f test-pod2 Running 15 seconds ago 84192e83ad40 2[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 84192e83ad40 32 seconds ago Up 32 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 042eee2a4d8f-infra 4497d0dd2ccd srv.world/fedora-nginx:latest /usr/sbin/nginx -... 32 seconds ago Up 32 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp sharp_chatterjee # run [mariadb] container and add it to the [test-pod2] [root@dlp ~]# podman run -dt --pod test-pod2 -e MYSQL_ROOT_PASSWORD=Password docker.io/library/mariadb db368b7c23d35ea38679321f6b845b08d65c718cdeca182ed6555a615d5e99af[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 84192e83ad40 About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 042eee2a4d8f-infra 4497d0dd2ccd srv.world/fedora-nginx:latest /usr/sbin/nginx -... About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp sharp_chatterjee db368b7c23d3 docker.io/library/mariadb:latest mariadbd 14 seconds ago Up 15 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp hopeful_noyce
[root@dlp ~]#
[root@dlp ~]# curl dlp.srv.world Dockerfile Test on Nginx mariadb -u root -p -h dlp.srv.world -e "show variables like 'hostname';" Enter password: +---------------+-----------+ | Variable_name | Value | +---------------+-----------+ | hostname | test-pod2 | +---------------+-----------+ |
| Sponsored Link |
|
|