Podman : Create Pods2020/11/06 |
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 ad33d7cbb03659fc1f1462391a678cd3dd6bc694232dab7f862a8a10c605908e # show pods [root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID ad33d7cbb036 test-pod Created 8 seconds ago 1 2e4b27a2af22 # show details of pod [root@dlp ~]# podman pod inspect test-pod { "Id": "ad33d7cbb03659fc1f1462391a678cd3dd6bc694232dab7f862a8a10c605908e", "Name": "test-pod", "Created": "2020-11-05T15:57:18.750919949+09: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_ad33d7cbb03659fc1f1462391a678cd3dd6bc694232dab7f862a8a10c605908e.slice", "CreateInfra": true, "InfraContainerID": "2e4b27a2af22abd462e62a93628f2adb524c34933993d0bb5f437a002c6035ee", "InfraConfig": { "PortBindings": { "80/tcp": [ { "HostIp": "", "HostPort": "8081" } ] }, "HostNetwork": false, "StaticIP": "", "StaticMAC": null, "NoManageResolvConf": false, "DNSServer": null, "DNSSearch": null, "DNSOption": null, "NoManageHosts": false, "HostAdd": null, "Networks": null }, "SharedNamespaces": [ "ipc", "net", "uts" ], "NumContainers": 1, "Containers": [ { "Id": "2e4b27a2af22abd462e62a93628f2adb524c34933993d0bb5f437a002c6035ee", "Name": "ad33d7cbb036-infra", "State": "configured" } ] }[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/nginx-server latest 5c98ec35fda6 5 hours ago 419 MB srv.world/fedora-httpd latest 56430ecb044d 5 hours ago 439 MB registry.fedoraproject.org/fedora latest 79fd58dc7611 8 days ago 181 MB docker.io/library/nginx latest f35646e83998 3 weeks ago 137 MB k8s.gcr.io/pause 3.2 80d28bedfe5d 8 months ago 688 kB # run container and add it to pod [root@dlp ~]# podman run -dt --pod test-pod srv.world/nginx-server 5cd040ee15f4f22c6bca086a8c17441324921c62942fcf6006f40638e1912c7a[root@dlp ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5cd040ee15f4 srv.world/nginx-server:latest /usr/sbin/nginx -... 7 seconds ago Up 7 seconds ago 0.0.0.0:8081->80/tcp boring_maxwell ..... ..... # verisy accesses [root@dlp ~]# curl localhost:8081 Podman Test on Nginx # stop pod [root@dlp ~]# podman pod stop test-pod ad33d7cbb03659fc1f1462391a678cd3dd6bc694232dab7f862a8a10c605908e # remove pod (removed containers all) [root@dlp ~]# podman pod rm test-pod --force ad33d7cbb03659fc1f1462391a678cd3dd6bc694232dab7f862a8a10c605908e |
[2] | It's possbile to create Pod and add Container with one command. |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/nginx-server latest 5c98ec35fda6 6 hours ago 419 MB srv.world/fedora-httpd latest 56430ecb044d 6 hours ago 439 MB registry.fedoraproject.org/fedora latest 79fd58dc7611 9 days ago 181 MB docker.io/library/nginx latest f35646e83998 3 weeks ago 137 MB registry.fedoraproject.org/f31/mariadb latest 7dae2805f59d 7 months ago 487 MB k8s.gcr.io/pause 3.2 80d28bedfe5d 8 months ago 688 kB # create a [test-pod2] pod and run Container [root@dlp ~]# podman run -dt --pod new:test-pod2 -p 80:80 -p 3306:3306 srv.world/nginx-server cdccf743338b324a7041742da890b257be9ddc3c92c130e4398d66a982fdcbb4[root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID 9dc3ad79dc0e test-pod2 Running 7 seconds ago 2 b7ec7cb02728[root@dlp ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cdccf743338b srv.world/nginx-server:latest /usr/sbin/nginx -... 20 seconds ago Up 20 seconds ago 0.0.0.0:80->80/tcp busy_ritchie ..... .....[root@dlp ~]# podman run -dt --pod test-pod2 -e MYSQL_ROOT_PASSWORD=Password registry.fedoraproject.org/f31/mariadb 93d6220d89e2bc466dc0268bb9fc65d7010739e7db4567f921a24c2635bf7065[root@dlp ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 93d6220d89e2 registry.fedoraproject.org/f31/mariadb:latest run-mysqld 9 seconds ago Up 8 seconds ago 0.0.0.0:80->80/tcp awesome_mestorf b7ec7cb02728 k8s.gcr.io/pause:3.2 About a minute ago Up About a minute ago 0.0.0.0:80->80/tcp 9dc3ad79dc0e-infra cdccf743338b srv.world/nginx-server:latest /usr/sbin/nginx -... About a minute ago Up About a minute ago 0.0.0.0:80->80/tcp busy_ritchie ..... .....
[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 |
|