Podman : Create Pods2025/01/21 |
|
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 e182edf4b8bca9b8c1bda8ce4134cea9be8afbb21ab23e67709866b60d666542 # show pods [root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS e182edf4b8bc test-pod Created 11 seconds ago ea6dcc14233e 1 # show details of pod [root@dlp ~]# podman pod inspect test-pod
[
{
"Id": "e182edf4b8bca9b8c1bda8ce4134cea9be8afbb21ab23e67709866b60d666542",
"Name": "test-pod",
"Created": "2025-01-21T16:39:54.964545699+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_e182edf4b8bca9b8c1bda8ce4134cea9be8afbb21ab23e67709866b60d666542.slice",
"CreateInfra": true,
"InfraContainerID": "ea6dcc14233ef7bbdc510d60d98bbb185ec744da6994073145e25d0f30328517",
"InfraConfig": {
"PortBindings": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8081"
}
]
},
"HostNetwork": false,
"StaticIP": "",
"StaticMAC": "",
"NoManageResolvConf": false,
"DNSServer": null,
"DNSSearch": null,
"DNSOption": null,
"NoManageHosts": false,
"HostAdd": null,
"Networks": [
"podman"
],
"NetworkOptions": null,
"pid_ns": "private",
"userns": "host",
"uts_ns": "private"
},
"SharedNamespaces": [
"ipc",
"net",
"uts"
],
"NumContainers": 1,
"Containers": [
{
"Id": "ea6dcc14233ef7bbdc510d60d98bbb185ec744da6994073145e25d0f30328517",
"Name": "e182edf4b8bc-infra",
"State": "created"
}
],
"LockNumber": 12
}
]
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 5.3.1-1733097600 d6ffe53ab076 55 seconds ago 701 kB srv.world/centos-nginx latest 451cd94e6c28 17 minutes ago 347 MB docker.io/library/root-web latest 3f60fa99e10d 20 minutes ago 347 MB srv.world/iproute latest dfa2b401b86c 3 hours ago 346 MB srv.world/centos-httpd latest ff3843182253 8 hours ago 354 MB quay.io/centos/centos stream10 1ef274445e32 7 days ago 311 MB docker.io/moby/buildkit buildx-stable-1 a72f628fa83e 5 weeks ago 207 MB docker.io/library/mariadb latest 6722945a6940 2 months ago 412 MB docker.io/library/registry latest 282bd1664cf1 15 months ago 26 MB # run container and add it to pod [root@dlp ~]# podman run -dt --pod test-pod srv.world/centos-nginx 611bd0debc382e0773907c756eda5c5a73095514fa3519f823f6758ce53925a8[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ea6dcc14233e localhost/podman-pause:5.3.1-1733097600 About a minute ago Up 10 seconds 0.0.0.0:8081->80/tcp e182edf4b8bc-infra 611bd0debc38 srv.world/centos-nginx:latest /usr/sbin/nginx -... 9 seconds ago Up 9 seconds 0.0.0.0:8081->80/tcp condescending_jones # 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 e182edf4b8bca9b8c1bda8ce4134cea9be8afbb21ab23e67709866b60d666542 |
| [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.3.1-1733097600 d6ffe53ab076 2 minutes ago 701 kB srv.world/centos-nginx latest 451cd94e6c28 19 minutes ago 347 MB docker.io/library/root-web latest 3f60fa99e10d 22 minutes ago 347 MB srv.world/iproute latest dfa2b401b86c 3 hours ago 346 MB srv.world/centos-httpd latest ff3843182253 8 hours ago 354 MB quay.io/centos/centos stream10 1ef274445e32 7 days ago 311 MB docker.io/moby/buildkit buildx-stable-1 a72f628fa83e 5 weeks ago 207 MB docker.io/library/mariadb latest 6722945a6940 2 months ago 412 MB docker.io/library/registry latest 282bd1664cf1 15 months ago 26 MB # create a [test_pod2] pod and add [srv.world/centos-nginx] container [root@dlp ~]# podman run -dt --pod new:test-pod2 -p 80:80 -p 3306:3306 srv.world/centos-nginx 70319ec8ae93089bb6881765988e740bb56d5a08c8c8fb55d6795edc7424847d[root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS b7a20f26f29a test-pod2 Running 10 seconds ago 2318a71cbee7 2[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2318a71cbee7 localhost/podman-pause:5.3.1-1733097600 23 seconds ago Up 23 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp b7a20f26f29a-infra 70319ec8ae93 srv.world/centos-nginx:latest /usr/sbin/nginx -... 23 seconds ago Up 23 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp busy_cartwright # run [mariadb] container and add it to the [test-pod2] [root@dlp ~]# podman run -dt --pod test-pod2 -e MYSQL_ROOT_PASSWORD=Password mariadb 82f5f78f6dab9894317cd7399f814318df7e5cb49055642c10172b8575fb1800[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2318a71cbee7 localhost/podman-pause:5.3.1-1733097600 About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp b7a20f26f29a-infra 70319ec8ae93 srv.world/centos-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 busy_cartwright 82f5f78f6dab docker.io/library/mariadb:latest mariadbd 9 seconds ago Up 9 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp determined_hoover
[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 |