Podman : Create Pods2026/05/07 |
|
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 --security-opt apparmor=unconfined 4621c8a8a1eee71d85211aab985758e255025e05c98778880017688254ffcae8 # show pods root@dlp:~# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 4621c8a8a1ee test-pod Created 10 seconds ago 1c02c2b84cfb 1 a551a0550afa pod_root Created 19 minutes ago 0 # show details of pod root@dlp:~# podman pod inspect test-pod
[
{
"Id": "4621c8a8a1eee71d85211aab985758e255025e05c98778880017688254ffcae8",
"Name": "test-pod",
"Created": "2026-05-07T00:49:29.68833778Z",
"CreateCommand": [
"podman",
"pod",
"create",
"-p",
"8081:80",
"-n",
"test-pod",
"--security-opt",
"apparmor=unconfined"
],
"ExitPolicy": "continue",
"State": "Created",
"Hostname": "",
"CreateCgroup": true,
"CgroupParent": "machine.slice",
"CgroupPath": "machine.slice/machine-libpod_pod_4621c8a8a1eee71d85211aab985758e255025e05c98778880017688254ffcae8.slice",
"CreateInfra": true,
"InfraContainerID": "1c02c2b84cfbdc811bd2cb43aeaed2c443981584cdc8bdc4706d0bd4756d3c4f",
"InfraConfig": {
"PortBindings": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8081"
.....
.....
root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/root_web latest 2b7dad1fb609 20 minutes ago 153 MB srv.world/iproute latest 761cdbcf586d 37 minutes ago 157 MB srv.world/ubuntu-nginx latest 4bb5563726cd 17 hours ago 153 MB srv.world/ubuntu-apache2 latest 53b7e6d878bc 17 hours ago 231 MB dlp.srv.world:5000/ubuntu my-registry 30ba44506a6d 2 weeks ago 111 MB docker.io/library/ubuntu latest 30ba44506a6d 2 weeks ago 111 MB docker.io/library/mariadb latest 8431e30f98d8 3 weeks ago 341 MB # run container and add it to pod root@dlp:~# podman run -dt --pod test-pod --security-opt apparmor=unconfined srv.world/ubuntu-nginx ba724c8973507bfe622221ca91655421017f1503f6d808133424311995089535root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1c02c2b84cfb About a minute ago Up 10 seconds 0.0.0.0:8081->80/tcp 4621c8a8a1ee-infra ba724c897350 srv.world/ubuntu-nginx:latest /usr/sbin/nginx -... 10 seconds ago Up 10 seconds 0.0.0.0:8081->80/tcp intelligent_bhabha # 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 4621c8a8a1eee71d85211aab985758e255025e05c98778880017688254ffcae8 |
| [2] | It's possible to create Pod and add Container with one command. |
|
root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/root_web latest 2b7dad1fb609 21 minutes ago 153 MB srv.world/iproute latest 761cdbcf586d 38 minutes ago 157 MB srv.world/ubuntu-nginx latest 4bb5563726cd 17 hours ago 153 MB srv.world/ubuntu-apache2 latest 53b7e6d878bc 17 hours ago 231 MB dlp.srv.world:5000/ubuntu my-registry 30ba44506a6d 2 weeks ago 111 MB docker.io/library/ubuntu latest 30ba44506a6d 2 weeks ago 111 MB docker.io/library/mariadb latest 8431e30f98d8 3 weeks ago 341 MB # create a [test_pod2] pod and add [srv.world/ubuntu-nginx] container root@dlp:~# podman run -dt --pod new:test-pod2 -p 80:80 -p 3306:3306 --security-opt apparmor=unconfined srv.world/ubuntu-nginx 61e1f8123ff3de25097a5c794a3bb0db832de9e7305417f8bf0b3a6081c173f83306root@dlp:~# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 1ab3793e55bd test-pod2 Running 12 seconds ago 28b8f7c78cde 2 a551a0550afa pod_root Created 22 minutes ago 0root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 28b8f7c78cde 31 seconds ago Up 32 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 1ab3793e55bd-infra 61e1f8123ff3 srv.world/ubuntu-nginx:latest /usr/sbin/nginx -... 31 seconds ago Up 32 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp awesome_meninsky # run [mariadb] container and add it to the [test-pod2] root@dlp:~# podman run -dt --pod test-pod2 --security-opt apparmor=unconfined -e MYSQL_ROOT_PASSWORD=Password docker.io/library/mariadb f8e025e222f11cbf71be2a04e5dc06005b0f897762e53ad53ec86450e6f4b3e1root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 28b8f7c78cde About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 1ab3793e55bd-infra 61e1f8123ff3 srv.world/ubuntu-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 awesome_meninsky f8e025e222f1 docker.io/library/mariadb:latest mariadbd 8 seconds ago Up 8 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp naughty_mclaren
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 |
|
|