Podman : Create Pods |
Create Pods like Kubernetes. | |
| [1] | Create a Pod and add a Container to it. |
# create an empty pod # -p [bind port] -n [pod name] root@dlp:~# podman pod create -p 8081:80 -n test-pod 339ef7e82ff66dc8a4427eb4ac7337f3473bb06ae3c61827693ab8dec9499e61 # show pods root@dlp:~# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 339ef7e82ff6 test-pod Created 10 seconds ago c99dbf2f26e3 1 # show details of pod root@dlp:~# podman pod inspect test-pod [
{
"Id": "339ef7e82ff66dc8a4427eb4ac7337f3473bb06ae3c61827693ab8dec9499e61",
"Name": "test-pod",
"Created": "2025-08-22T10:13:27.612113034+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_339ef7e82ff66dc8a4427eb4ac7337f3473bb06ae3c61827693ab8dec9499e61.slice",
"CreateInfra": true,
"InfraContainerID": "c99dbf2f26e3387d97bbc5907ce1e217b7888cceadf3f0e89a6ffdaac1a90ea1",
"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": [
"ipc",
"net",
"uts"
],
"NumContainers": 1,
"Containers": [
{
"Id": "c99dbf2f26e3387d97bbc5907ce1e217b7888cceadf3f0e89a6ffdaac1a90ea1",
"Name": "339ef7e82ff6-infra",
"State": "created"
}
],
"LockNumber": 16
}
]
root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 5.4.2-1753478586 ddf2e42fec3b About a minute ago 737 kB docker.io/library/root-web latest 3cc41f7733a0 7 minutes ago 157 MB srv.world/iproute latest 77debccd9811 18 minutes ago 156 MB srv.world/debian-nginx latest 33b7b5b10b13 47 minutes ago 157 MB srv.world/debian-apache2 latest a0aca892bf29 55 minutes ago 234 MB docker.io/library/debian latest 047bd8d81940 11 days ago 124 MB docker.io/library/mariadb latest 300929c28ab7 13 days ago 336 MB docker.io/moby/buildkit buildx-stable-1 44f5d48d5c6c 7 weeks ago 219 MB # run container and add it to pod root@dlp:~# podman run -dt --pod test-pod srv.world/debian-nginx b8d5bde3886364407143685ef9fef3011e06d49f69a42ed1c1565e031406598droot@dlp:~# podman ps ONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c99dbf2f26e3 localhost/podman-pause:5.4.2-1753478586 About a minute ago Up 12 seconds 0.0.0.0:8081->80/tcp 339ef7e82ff6-infra b8d5bde38863 srv.world/debian-nginx:latest /usr/sbin/nginx -... 11 seconds ago Up 12 seconds 0.0.0.0:8081->80/tcp objective_ishizaka # 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 339ef7e82ff66dc8a4427eb4ac7337f3473bb06ae3c61827693ab8dec9499e61 |
| [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-1753478586 ddf2e42fec3b 2 minutes ago 737 kB docker.io/library/root-web latest 3cc41f7733a0 9 minutes ago 157 MB srv.world/iproute latest 77debccd9811 20 minutes ago 156 MB srv.world/debian-nginx latest 33b7b5b10b13 48 minutes ago 157 MB srv.world/debian-apache2 latest a0aca892bf29 56 minutes ago 234 MB docker.io/library/debian latest 047bd8d81940 11 days ago 124 MB docker.io/library/mariadb latest 300929c28ab7 13 days ago 336 MB docker.io/moby/buildkit buildx-stable-1 44f5d48d5c6c 7 weeks ago 219 MB # create a [test_pod2] pod and add [srv.world/debian-nginx] container root@dlp:~# podman run -dt --pod new:test-pod2 -p 80:80 -p 3306:3306 srv.world/debian-nginx ffdc94707416181a5ce8db476658a6da52c33cc5be09b09520ad82382067907aroot@dlp:~# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS f9b4ae4b9c78 test-pod2 Running 10 seconds ago 3035811033d7 2root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3035811033d7 localhost/podman-pause:5.4.2-1753478586 23 seconds ago Up 23 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp f9b4ae4b9c78-infra ffdc94707416 srv.world/debian-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 admiring_jemison # 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 3692d6437e5e951bd7f2f48abfc73f381d56e17aad4043b2409cdaf19c4221d1root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3035811033d7 localhost/podman-pause:5.4.2-1753478586 About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp f9b4ae4b9c78-infra ffdc94707416 srv.world/debian-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 admiring_jemison 3692d6437e5e docker.io/library/mariadb:latest mariadbd 8 seconds ago Up 9 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp modest_cohen 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 | +---------------+-----------+ |
No comments:
Post a Comment