Podman : Pod を作成する2021/05/14 |
Kubernetes でおなじみの Pod も Podman で作成可能です。
|
|
[1] | Pod を作成してコンテナーを追加します。 |
# 空の pod を新規作成 # -p [バインドするポート] -n [pod の名前] [root@dlp ~]# podman pod create -p 8081:80 -n test-pod 71003c6f96171c46c9619eba56be3238c33186bc66b9d4fd8fea551cda113e35 # 確認 [root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 71003c6f9617 test-pod Created 10 seconds ago c8fb08d89c38 1 # pod の詳細を表示 [root@dlp ~]# podman pod inspect test-pod { "Id": "71003c6f96171c46c9619eba56be3238c33186bc66b9d4fd8fea551cda113e35", "Name": "test-pod", "Created": "2021-05-13T03:56:08.299508215-04: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_71003c6f96171c46c9619eba56be3238c33186bc66b9d4fd8fea551cda113e35.slice", "CreateInfra": true, "InfraContainerID": "c8fb08d89c385ff722af56854930caba442a3f29ebde70aaf5aa495b3245ad29", "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": "c8fb08d89c385ff722af56854930caba442a3f29ebde70aaf5aa495b3245ad29", "Name": "71003c6f9617-infra", "State": "configured" } ] }[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/fedora-nginx latest ef4fd3a3964f 3 seconds ago 425 MB registry.fedoraproject.org/fedora latest 5f05951e2065 2 weeks ago 187 MB docker.io/library/mariadb latest 992bce5ed710 2 weeks ago 407 MB k8s.gcr.io/pause 3.5 ed210e3e4a5b 8 weeks ago 690 kB # コンテナーを起動して pod に追加する [root@dlp ~]# podman run -dt --pod test-pod srv.world/fedora-nginx 034a8fb9384ccd61f1a78027dced9a702b0deae74f61bf40021b75a43bfa0804[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c8fb08d89c38 k8s.gcr.io/pause:3.5 4 minutes ago Up 7 seconds ago 0.0.0.0:8081->80/tcp 71003c6f9617-infra 034a8fb9384c srv.world/fedora-nginx:latest /usr/sbin/nginx -... 6 seconds ago Up 7 seconds ago 0.0.0.0:8081->80/tcp hopeful_bartik # アクセス確認 [root@dlp ~]# curl localhost:8081 Podman Test on Nginx # pod を停止する [root@dlp ~]# podman pod stop test-pod 71003c6f96171c46c9619eba56be3238c33186bc66b9d4fd8fea551cda113e35 # pod を削除する (コンテナーも含めて強制削除) [root@dlp ~]# podman pod rm test-pod --force 71003c6f96171c46c9619eba56be3238c33186bc66b9d4fd8fea551cda113e35 |
[2] | Pod の作成とコンテナーの追加を同時に実行することもできます。 |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/fedora-nginx latest ef4fd3a3964f About a minute ago 425 MB registry.fedoraproject.org/fedora latest 5f05951e2065 2 weeks ago 187 MB docker.io/library/mariadb latest 992bce5ed710 2 weeks ago 407 MB k8s.gcr.io/pause 3.5 ed210e3e4a5b 8 weeks ago 690 kB # [test-pod2] を新規作成して [srv.world/fedora-nginx] コンテナーを追加する [root@dlp ~]# podman run -dt --pod new:test-pod2 -p 80:80 -p 3306:3306 srv.world/fedora-nginx 9c9a53ba729fdd097bb91cba22d8a8b4a5590c9bbf2d669f8aed7668b0a77fdb[root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 30f8c1756117 test-pod2 Running 16 seconds ago d495a8abb00e 2[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d495a8abb00e k8s.gcr.io/pause:3.5 26 seconds ago Up 26 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 30f8c1756117-infra 9c9a53ba729f srv.world/fedora-nginx:latest /usr/sbin/nginx -... 26 seconds ago Up 26 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp unruffled_murdock # [mariadb] コンテナーを起動して [test-pod2] に追加する [root@dlp ~]# podman run -dt --pod test-pod2 -e MYSQL_ROOT_PASSWORD=Password docker.io/library/mariadb 13993b796a3e54b26e130b989c8e08e12b5c59bb8dde2dbca9a1ed7fd32b9430[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d495a8abb00e k8s.gcr.io/pause:3.5 About a minute ago Up About a minute ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 30f8c1756117-infra 9c9a53ba729f srv.world/fedora-nginx:latest /usr/sbin/nginx -... About a minute ago Up About a minute ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp unruffled_murdock 13993b796a3e docker.io/library/mariadb:latest mysqld 14 seconds ago Up 14 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp romantic_mayer
[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 |
|