Podman : Create Pods2019/10/11 |
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 d688dbff0b271ad2fbefbfdc9259509d8877572f95983bb3f2f6b57b253bc074 # show pods [root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID d688dbff0b27 test_pod Running About a minute ago 1 c2dffc8dbcfa # show details of pod [root@dlp ~]# podman pod inspect test_pod { "Config": { "id": "d688dbff0b271ad2fbefbfdc9259509d8877572f95983bb3f2f6b57b253bc074", "name": "test_pod", "labels": null, "cgroupParent": "machine.slice", "sharesCgroup": true, "sharesIpc": true, "sharesNet": true, "sharesUts": true, "infraConfig": { "makeInfraContainer": true, "infraPortBindings": [ { "hostPort": 8081, "containerPort": 80, "protocol": "tcp", "hostIP": "" } ] }, "created": "2019-10-11T14:38:06.494546769+09:00" }, "State": { "cgroupPath": "machine.slice/machine-libpod_pod_d688dbff0b271ad2fbefbfdc9259509d8877572f95983bb3f2f6b57b253bc074.slice", "infraContainerID": "c2dffc8dbcfae4662d844ae222b6d2f92e1791ac1f759b1cb51feb2aaae75dfe" }, "Containers": [ { "id": "c2dffc8dbcfae4662d844ae222b6d2f92e1791ac1f759b1cb51feb2aaae75dfe", "state": "running" } ] }[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/nginx_server latest 41c48e1d2421 15 hours ago 308 MB srv.world/centos_httpd latest 67edc4066f76 21 hours ago 368 MB docker.io/library/centos latest 0f3e07c0138f 9 days ago 227 MB docker.io/library/registry 2 f32a97de94e1 7 months ago 26.4 MB quay.io/libpod/alpine_nginx latest 3ef70f7291f4 11 months ago 9.21 MB k8s.gcr.io/pause 3.1 da86e6ba6ca1 21 months ago 747 kB # run container and add it to pod [root@dlp ~]# podman run -dt --pod test_pod srv.world/nginx_server 924aff9ec480aa2e2b611b4c16e7df85f1ffb8d045dce946fbc53367ea99f264[root@dlp ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 924aff9ec480 srv.world/nginx_server:latest /usr/sbin/nginx -... 4 minutes ago Up 4 minutes ago zen_keller c2dffc8dbcfa k8s.gcr.io/pause:3.1 11 minutes ago Up 11 minutes ago 0.0.0.0:8081->80/tcp d688dbff0b27-infra # verisy accesses [root@dlp ~]# curl localhost:8081 Podman Test on Nginx # stop pod [root@dlp ~]# podman pod stop test_pod d688dbff0b271ad2fbefbfdc9259509d8877572f95983bb3f2f6b57b253bc074 # remove pod (removed containers all) [root@dlp ~]# podman pod rm test_pod --force d688dbff0b271ad2fbefbfdc9259509d8877572f95983bb3f2f6b57b253bc074 |
[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 41c48e1d2421 15 hours ago 308 MB srv.world/centos_httpd latest 67edc4066f76 22 hours ago 368 MB docker.io/library/centos latest 0f3e07c0138f 9 days ago 227 MB docker.io/library/registry 2 f32a97de94e1 7 months ago 26.4 MB quay.io/libpod/alpine_nginx latest 3ef70f7291f4 11 months ago 9.21 MB k8s.gcr.io/pause 3.1 da86e6ba6ca1 21 months ago 747 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 7155112d6c1993949c230719ee1f5239266e95dabda1c6746e60cca30867935d[root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID a3c2dae83c3f test_pod2 Running 11 seconds ago 2 f38a5347001b[root@dlp ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7155112d6c19 srv.world/nginx_server:latest /usr/sbin/nginx -... 19 seconds ago Up 19 seconds ago dazzling_bassi f38a5347001b k8s.gcr.io/pause:3.1 19 seconds ago Up 19 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp a3c2dae83c3f-infra[root@dlp ~]# podman run -dt --pod test_pod2 -e MYSQL_ROOT_PASSWORD=Password mariadb 62a8fdaefec08e0cfa7a08e1a9ccdcd07cc39ea4ae5279dbe1e0774ac8305488[root@dlp ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 62a8fdaefec0 docker.io/library/mariadb:latest docker-entrypoint... 12 seconds ago Up 11 seconds ago keen_franklin 7155112d6c19 srv.world/nginx_server:latest /usr/sbin/nginx -... 50 seconds ago Up 50 seconds ago dazzling_bassi f38a5347001b k8s.gcr.io/pause:3.1 50 seconds ago Up 50 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp a3c2dae83c3f-infra
[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 | 62a8fdaefec0 | +---------------+--------------+ |
Sponsored Link |
|