Podman : Create Pods2023/04/26 |
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 e443fe08cd8341304d45d07f3443baa8c4c19505ee67b461c85d08eb10986d94 # show pods [root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS e443fe08cd83 test-pod Created 11 seconds ago 617b4301fc49 1 # show details of pod [root@dlp ~]# podman pod inspect test-pod { "Id": "e443fe08cd8341304d45d07f3443baa8c4c19505ee67b461c85d08eb10986d94", "Name": "test-pod", "Created": "2023-04-26T13:37:39.321163073+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_e443fe08cd8341304d45d07f3443baa8c4c19505ee67b461c85d08eb10986d94.slice", "CreateInfra": true, "InfraContainerID": "617b4301fc49db5a14e8b84fe954bf5b33a202b6709403f1b278840f0334698a", "InfraConfig": { "PortBindings": { "80/tcp": [ { "HostIp": "", "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": "617b4301fc49db5a14e8b84fe954bf5b33a202b6709403f1b278840f0334698a", "Name": "e443fe08cd83-infra", "State": "created" } ] }[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 4.5.0-1681486942 aaf574b56683 51 seconds ago 1.11 MB srv.world/iproute latest 2e299c1e83df 6 minutes ago 392 MB localhost/root_web latest 0d673ea4df4c 2 hours ago 420 MB srv.world/fedora-nginx latest 97533117cdc8 3 hours ago 420 MB srv.world/fedora-httpd latest 51d32e13e2f4 3 hours ago 477 MB registry.fedoraproject.org/fedora latest c9bfca6d0ac2 6 days ago 196 MB dlp.srv.world:5000/fedora my-registry c9bfca6d0ac2 6 days ago 196 MB docker.io/library/mariadb latest 4a632f970181 5 weeks ago 407 MB # run container and add it to pod [root@dlp ~]# podman run -dt --pod test-pod srv.world/fedora-nginx 309fd25e09ee1c908d687a126a461ec7c4f69233fc71bc0b826cd13ca4f0ca1f[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 617b4301fc49 localhost/podman-pause:4.5.0-1681486942 About a minute ago Up 9 seconds 0.0.0.0:8081->80/tcp e443fe08cd83-infra 309fd25e09ee srv.world/fedora-nginx:latest /usr/sbin/nginx -... 9 seconds ago Up 9 seconds 0.0.0.0:8081->80/tcp practical_goodall # verify accesses [root@dlp ~]# curl localhost:8081 Podman Test on Nginx # stop pod [root@dlp ~]# podman pod stop test-pod e443fe08cd8341304d45d07f3443baa8c4c19505ee67b461c85d08eb10986d94 # remove pod (removed containers all) [root@dlp ~]# podman pod rm test-pod --force e443fe08cd8341304d45d07f3443baa8c4c19505ee67b461c85d08eb10986d94 |
[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 4.5.0-1681486942 aaf574b56683 2 minutes ago 1.11 MB srv.world/iproute latest 2e299c1e83df 8 minutes ago 392 MB localhost/root_web latest 0d673ea4df4c 2 hours ago 420 MB srv.world/fedora-nginx latest 97533117cdc8 3 hours ago 420 MB srv.world/fedora-httpd latest 51d32e13e2f4 3 hours ago 477 MB registry.fedoraproject.org/fedora latest c9bfca6d0ac2 6 days ago 196 MB dlp.srv.world:5000/fedora my-registry c9bfca6d0ac2 6 days ago 196 MB docker.io/library/mariadb latest 4a632f970181 5 weeks ago 407 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 f0c1386ee2700f1eef5f43bca5fd04b48b9fbff0b2354e24698ff70d7fd15ce4[root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 908c335d840e test-pod2 Running 10 seconds ago 08968d3af9c6 2[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 08968d3af9c6 localhost/podman-pause:4.5.0-1681486942 27 seconds ago Up 27 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 908c335d840e-infra f0c1386ee270 srv.world/fedora-nginx:latest /usr/sbin/nginx -... 27 seconds ago Up 27 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp stoic_banzai # 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 04a69d9818a4644b06dcbeffe77445d9be12b1cf77018bb3592da4119791b9da[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 08968d3af9c6 localhost/podman-pause:4.5.0-1681486942 About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 908c335d840e-infra f0c1386ee270 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 stoic_banzai 04a69d9818a4 docker.io/library/mariadb:latest mariadbd 9 seconds ago Up 10 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp eloquent_poincare
[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 |