Podman : Pod を作成する2022/03/14 |
Kubernetes でおなじみの Pod も Podman で作成可能です。
|
|
[1] | Pod を作成してコンテナーを追加します。 |
# 空の pod を新規作成 # -p [バインドするポート] -n [pod の名前] [root@dlp ~]# podman pod create -p 8081:80 -n test-pod bdf487d4c6918e0a17bedd71f0fe19df38497db670bf2098155b890e2f82b593 # 確認 [root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS bdf487d4c691 test-pod Created 7 seconds ago 17def5b06bd3 1 # pod の詳細を表示 [root@dlp ~]# podman pod inspect test-pod { "Id": "bdf487d4c6918e0a17bedd71f0fe19df38497db670bf2098155b890e2f82b593", "Name": "test-pod", "Created": "2022-03-14T12:43:45.353771267+09:00", "CreateCommand": [ "podman", "pod", "create", "-p", "8081:80", "-n", "test-pod" ], "State": "Created", "Hostname": "", "CreateCgroup": true, "CgroupParent": "machine.slice", "CgroupPath": "machine.slice/machine-libpod_pod_bdf487d4c6918e0a17bedd71f0fe19df38497db670bf2098155b890e2f82b593.slice", "CreateInfra": true, "InfraContainerID": "17def5b06bd350ad389008ef695094c29a1247a583297b21d1486c5766f3afe6", "InfraConfig": { "PortBindings": { "80/tcp": [ { "HostIp": "", "HostPort": "8081" } ] }, "HostNetwork": true, "StaticIP": "", "StaticMAC": "", "NoManageResolvConf": false, "DNSServer": null, "DNSSearch": null, "DNSOption": null, "NoManageHosts": false, "HostAdd": null, "Networks": [ "podman" ], "NetworkOptions": null, "pid_ns": "private", "userns": "host" }, "SharedNamespaces": [ "ipc", "net", "uts" ], "NumContainers": 1, "Containers": [ { "Id": "17def5b06bd350ad389008ef695094c29a1247a583297b21d1486c5766f3afe6", "Name": "bdf487d4c691-infra", "State": "created" } ] }[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 4.0.0-1645764745 b03d3f09b431 38 seconds ago 812 kB docker.io/library/root_web latest b82379313273 52 minutes ago 247 MB localhost/root_web latest 6190fc2fcb25 52 minutes ago 247 MB srv.world/centos-nginx latest 762eb0a249a5 2 hours ago 247 MB srv.world/centos-httpd latest 0c6c507d6e95 2 hours ago 253 MB docker.io/library/mariadb latest f5dd1ac0b00e 3 days ago 421 MB quay.io/centos/centos stream9 44ffcc4acee8 3 days ago 152 MB docker.io/library/registry 2 8948869ebfee 5 days ago 24.7 MB # コンテナーを起動して pod に追加する [root@dlp ~]# podman run -dt --pod test-pod srv.world/centos-nginx 5410cefbdbd61a15e074df0c0dc9adf9aa2ab0785754a079f0a82c8e6ad24df1[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 17def5b06bd3 localhost/podman-pause:4.0.0-1645764745 About a minute ago Up 7 seconds ago 0.0.0.0:8081->80/tcp bdf487d4c691-infra 5410cefbdbd6 srv.world/centos-nginx:latest /usr/sbin/nginx -... 7 seconds ago Up 7 seconds ago 0.0.0.0:8081->80/tcp gracious_ellis # アクセス確認 [root@dlp ~]# curl localhost:8081 Podman Test on Nginx # pod を停止する [root@dlp ~]# podman pod stop test-pod bdf487d4c6918e0a17bedd71f0fe19df38497db670bf2098155b890e2f82b593 # pod を削除する (コンテナーも含めて強制削除) [root@dlp ~]# podman pod rm test-pod --force bdf487d4c6918e0a17bedd71f0fe19df38497db670bf2098155b890e2f82b593 |
[2] | Pod の作成とコンテナーの追加を同時に実行することもできます。 |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 4.0.0-1645764745 b03d3f09b431 About a minute ago 812 kB docker.io/library/root_web latest b82379313273 53 minutes ago 247 MB localhost/root_web latest 6190fc2fcb25 53 minutes ago 247 MB srv.world/centos-nginx latest 762eb0a249a5 2 hours ago 247 MB srv.world/centos-httpd latest 0c6c507d6e95 2 hours ago 253 MB docker.io/library/mariadb latest f5dd1ac0b00e 3 days ago 421 MB quay.io/centos/centos stream9 44ffcc4acee8 3 days ago 152 MB docker.io/library/registry 2 8948869ebfee 5 days ago 24.7 MB # [test-pod2] を新規作成して [srv.world/centos-nginx] コンテナーを追加する [root@dlp ~]# podman run -dt --pod new:test-pod2 -p 80:80 -p 3306:3306 srv.world/centos-nginx 02cbf5bbd55accd5e9d72277037586fceb99c2730ceb5074fc59721507d37170[root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 0f4f7e83351d test-pod2 Running 7 seconds ago 1feba853e2d1 2[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1feba853e2d1 localhost/podman-pause:4.0.0-1645764745 19 seconds ago Up 20 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 0f4f7e83351d-infra 02cbf5bbd55a srv.world/centos-nginx:latest /usr/sbin/nginx -... 19 seconds ago Up 20 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp kind_kepler # [mariadb] コンテナーを起動して [test-pod2] に追加する [root@dlp ~]# podman run -dt --pod test-pod2 -e MYSQL_ROOT_PASSWORD=Password mariadb 70e1c460e9bd7243f8372ec0812263264e9dc54cac1cdeb9fa23ecc25440c527[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1feba853e2d1 localhost/podman-pause:4.0.0-1645764745 50 seconds ago Up 51 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 0f4f7e83351d-infra 02cbf5bbd55a srv.world/centos-nginx:latest /usr/sbin/nginx -... 50 seconds ago Up 51 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp kind_kepler 70e1c460e9bd docker.io/library/mariadb:latest mariadbd 6 seconds ago Up 7 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp hungry_mestorf
[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 |