Podman : Create Pods2025/04/25 |
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 51d5a9940ddb628d19d27c5b78adf6287337ba61bde4a6eed81dcdcc9c69972b # show pods [root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 51d5a9940ddb test-pod Created 6 minutes ago de8cd739632a 1 # show details of pod [root@dlp ~]# podman pod inspect test-pod [ { "Id": "51d5a9940ddb628d19d27c5b78adf6287337ba61bde4a6eed81dcdcc9c69972b", "Name": "test-pod", "Created": "2025-04-25T16:32:40.756464525+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_51d5a9940ddb628d19d27c5b78adf6287337ba61bde4a6eed81dcdcc9c69972b.slice", "CreateInfra": true, "InfraContainerID": "de8cd739632a1e816e20663e67da067e4e770ae95306f66172a2e0b2fb43a337", "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": "de8cd739632a1e816e20663e67da067e4e770ae95306f66172a2e0b2fb43a337", "Name": "51d5a9940ddb-infra", "State": "created" } ], "LockNumber": 9 } ][root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 5.4.2-1743552000 44beb5bc0a3a 8 minutes ago 776 kB srv.world/iproute latest aa9549af2c42 2 hours ago 258 MB docker.io/library/root-web latest 6b8099ee8b9d 2 hours ago 325 MB srv.world/fedora-nginx latest ad26e76247bd 3 hours ago 325 MB srv.world/fedora-httpd latest 512d39041a55 3 hours ago 328 MB registry.fedoraproject.org/fedora latest e5bf03515e92 25 hours ago 166 MB docker.io/library/mariadb latest 9f3d79eba61e 2 months ago 334 MB # run container and add it to pod [root@dlp ~]# podman run -dt --pod test-pod srv.world/fedora-nginx 1ac71ca46ffa56e3eed1f60f8479f06aef4ddb2e4f510e9e95ca6aadf7423dc8[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES de8cd739632a localhost/podman-pause:5.4.2-1743552000 9 minutes ago Up 21 seconds 0.0.0.0:8081->80/tcp 51d5a9940ddb-infra 1ac71ca46ffa srv.world/fedora-nginx:latest /usr/sbin/nginx -... 21 seconds ago Up 21 seconds 0.0.0.0:8081->80/tcp relaxed_kowalevski # 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 51d5a9940ddb628d19d27c5b78adf6287337ba61bde4a6eed81dcdcc9c69972b |
[2] | It's possible to create Pod and add Container with one command. |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 5.4.2-1743552000 44beb5bc0a3a 10 minutes ago 776 kB srv.world/iproute latest aa9549af2c42 2 hours ago 258 MB docker.io/library/root-web latest 6b8099ee8b9d 2 hours ago 325 MB srv.world/fedora-nginx latest ad26e76247bd 3 hours ago 325 MB srv.world/fedora-httpd latest 512d39041a55 3 hours ago 328 MB registry.fedoraproject.org/fedora latest e5bf03515e92 25 hours ago 166 MB docker.io/library/mariadb latest 9f3d79eba61e 2 months ago 334 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 b5950641922b3a5511d67b3927a182fe95935447be34e9680005d09e5d54cbeb[root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 32aaa3b80f9c test-pod2 Running 22 seconds ago f7efddd2e7cd 2[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f7efddd2e7cd localhost/podman-pause:5.4.2-1743552000 41 seconds ago Up 41 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 32aaa3b80f9c-infra b5950641922b srv.world/fedora-nginx:latest /usr/sbin/nginx -... 41 seconds ago Up 41 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp eager_nash # 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 83e2f0f75ed8d3d1cc6cb5e2fb23f70cf2b94e69a77768a873828c07f004aa3c[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f7efddd2e7cd localhost/podman-pause:5.4.2-1743552000 About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 32aaa3b80f9c-infra b5950641922b 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 eager_nash 83e2f0f75ed8 docker.io/library/mariadb:latest mariadbd 17 seconds ago Up 18 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp suspicious_almeida
[root@dlp ~]#
[root@dlp ~]# curl dlp.srv.world Dockerfile Test on Nginx mysql -u root -p -h dlp.srv.world -e "show variables like 'hostname';" Enter password: +---------------+-----------+ | Variable_name | Value | +---------------+-----------+ | hostname | test-pod2 | +---------------+-----------+ |
Sponsored Link |
|