Podman : Pod を作成する2021/08/28 |
Kubernetes でおなじみの Pod も Podman で作成可能です。
|
|
[1] | Pod を作成してコンテナーを追加します。 |
# 空の pod を新規作成 # -p [バインドするポート] -n [pod の名前] root@dlp:~# podman pod create -p 8081:80 -n test-pod 01d10e5c8a5ab59a0cc11d297d3ee660ef689bfc3b4af94fec6dee7ce9259d00 # 確認 root@dlp:~# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 01d10e5c8a5a test-pod Created 18 seconds ago 01547bd444b4 1 # pod の詳細を表示 root@dlp:~# podman pod inspect test-pod { "Id": "01d10e5c8a5ab59a0cc11d297d3ee660ef689bfc3b4af94fec6dee7ce9259d00", "Name": "test-pod", "Created": "2021-08-27T08:12:25.666649399-05:00", "CreateCommand": [ "podman", "pod", "create", "-p", "8081:80", "-n", "test-pod" ], "State": "Created", "Hostname": "test-pod", "CreateCgroup": true, "CgroupParent": "machine.slice", "CgroupPath": "machine.slice/machine-libpod_pod_01d10e5c8a5ab59a0cc11d297d3ee660ef689bfc3b4af94fec6dee7ce9259d00.slice", "CreateInfra": true, "InfraContainerID": "01547bd444b458fa49afd82c39a72ca494378cd513940cc7b0b0547c2678c2b4", "InfraConfig": { "PortBindings": { "80/tcp": [ { "HostIp": "", "HostPort": "8081" } ] }, "HostNetwork": false, "StaticIP": "", "StaticMAC": "", "NoManageResolvConf": false, "DNSServer": null, "DNSSearch": null, "DNSOption": null, "NoManageHosts": false, "HostAdd": null, "Networks": null, "NetworkOptions": null }, "SharedNamespaces": [ "net", "uts", "ipc" ], "NumContainers": 1, "Containers": [ { "Id": "01547bd444b458fa49afd82c39a72ca494378cd513940cc7b0b0547c2678c2b4", "Name": "01d10e5c8a5a-infra", "State": "configured" } ] }root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/debian-nginx latest 37125087a75f 5 hours ago 216 MB srv.world/debian-apache2 latest 68a7269c5457 5 hours ago 260 MB docker.io/library/debian latest fe3c5de03486 10 days ago 129 MB docker.io/library/registry 2 1fd8e1b0bb7e 4 months ago 26.8 MB k8s.gcr.io/pause 3.2 80d28bedfe5d 18 months ago 688 kB # コンテナーを起動して pod に追加する root@dlp:~# podman run -dt --pod test-pod srv.world/debian-nginx 0c2c5933cf1c4b873b37eba8ea9f20846953614a46a54e5dc9d7bf6d7dfb80abroot@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 01547bd444b4 k8s.gcr.io/pause:3.2 9 minutes ago Up 4 minutes ago 0.0.0.0:8081->80/tcp 01d10e5c8a5a-infra 0c2c5933cf1c srv.world/debian-nginx /usr/sbin/nginx -... 4 minutes ago Up 4 minutes ago 0.0.0.0:8081->80/tcp fervent_dewdney # アクセス確認 root@dlp:~# curl localhost:8081 Podman Test on Nginx # pod を停止する root@dlp:~# podman pod stop test-pod 01d10e5c8a5ab59a0cc11d297d3ee660ef689bfc3b4af94fec6dee7ce9259d00 # pod を削除する (コンテナーも含めて強制削除) root@dlp:~# podman pod rm test-pod --force 01d10e5c8a5ab59a0cc11d297d3ee660ef689bfc3b4af94fec6dee7ce9259d00 |
[2] | Pod の作成とコンテナーの追加を同時に実行することもできます。 |
root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/debian-nginx latest 37125087a75f 5 hours ago 216 MB srv.world/debian-apache2 latest 68a7269c5457 5 hours ago 260 MB docker.io/library/debian latest fe3c5de03486 10 days ago 129 MB docker.io/library/registry 2 1fd8e1b0bb7e 4 months ago 26.8 MB k8s.gcr.io/pause 3.2 80d28bedfe5d 18 months ago 688 kB # [test-pod2] を新規作成して [srv.world/centos-nginx] コンテナーを追加する root@dlp:~# podman run -dt --pod new:test-pod2 -p 80:80 -p 3306:3306 srv.world/debian-nginx 65f3e3b9bdfe9235f3b9e7ec6ff6d77dd7e28a7d45772858b0436876d2a4334eroot@dlp:~# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS a8d444adc7a8 test-pod2 Running About a minute ago c6fa24807d1b 2root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c6fa24807d1b k8s.gcr.io/pause:3.2 4 minutes ago Up 4 minutes ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp a8d444adc7a8-infra 65f3e3b9bdfe srv.world/debian-nginx /usr/sbin/nginx -... 4 minutes ago Up 4 minutes ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp xenodochial_wing # [mariadb] コンテナーを起動して [test-pod2] に追加する root@dlp:~# podman run -dt --pod test-pod2 -e MYSQL_ROOT_PASSWORD=Password docker.io/library/mariadb 035b03d1f9736be45e4e5d44e6e637ec6fdfd0e519324be523c1e91d52402fabroot@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c6fa24807d1b k8s.gcr.io/pause:3.2 16 minutes ago Up 16 minutes ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp a8d444adc7a8-infra 65f3e3b9bdfe srv.world/debian-nginx /usr/sbin/nginx -... 16 minutes ago Up 16 minutes ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp xenodochial_wing 035b03d1f973 docker.io/library/mariadb:latest mysqld 6 minutes ago Up 6 minutes ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp elated_saha
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 |