Podman : Create Pods2020/05/11 |
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 953c902fd9430ac86dd38169aa002594399144f19246be1295f7814f39bd72d7 # show pods [root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID 953c902fd943 test_pod Created 10 seconds ago 1 69389ebf474f # show details of pod [root@dlp ~]# podman pod inspect test_pod { "Config": { "id": "953c902fd9430ac86dd38169aa002594399144f19246be1295f7814f39bd72d7", "name": "test_pod", "hostname": "test_pod", "labels": { }, "cgroupParent": "machine.slice", "sharesCgroup": true, "sharesIpc": true, "sharesNet": true, "sharesUts": true, "infraConfig": { "makeInfraContainer": true, "infraPortBindings": [ { "hostPort": 8081, "containerPort": 80, "protocol": "tcp", "hostIP": "" } ] }, "created": "2020-05-11T11:28:36.949330512+09:00", "lockID": 12 }, "State": { "cgroupPath": "machine.slice/machine-libpod_pod_953c902fd9430ac86dd38169aa002594399144f19246be1295f7814f39bd72d7.slice", "infraContainerID": "69389ebf474f512a887b5e23194fd739e4b0ec3ef761aeae2c9c1715deda5a36", "status": "Created" }, "Containers": [ { "id": "69389ebf474f512a887b5e23194fd739e4b0ec3ef761aeae2c9c1715deda5a36", "state": "configured" } ] }[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/nginx_server latest f0bde03754eb 38 minutes ago 406 MB dlp.srv.world:5000/nginx_server latest f0bde03754eb 38 minutes ago 406 MB srv.world/fedora_httpd latest a461b4b0b704 42 minutes ago 452 MB registry.fedoraproject.org/fedora latest d81c91deec0d 11 days ago 208 MB k8s.gcr.io/pause 3.2 80d28bedfe5d 2 months ago 688 kB docker.io/library/registry 2 708bc6af7e5e 3 months ago 26.3 MB # run container and add it to pod [root@dlp ~]# podman run -dt --pod test_pod srv.world/nginx_server 9047ef44c13eee5f8f2ab9848a833cb4c8f8cfc6c7dbfe2dc259a850819083ec[root@dlp ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9047ef44c13e srv.world/nginx_server:latest /usr/sbin/nginx -... About a minute ago Up About a minute ago 0.0.0.0:8081->80/tcp agitated_almeida ..... ..... # verisy accesses [root@dlp ~]# curl localhost:8081 Podman Test on Nginx # stop pod [root@dlp ~]# podman pod stop test_pod 953c902fd9430ac86dd38169aa002594399144f19246be1295f7814f39bd72d7 # remove pod (removed containers all) [root@dlp ~]# podman pod rm test_pod --force 953c902fd9430ac86dd38169aa002594399144f19246be1295f7814f39bd72d7 |
[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 f0bde03754eb 41 minutes ago 406 MB dlp.srv.world:5000/nginx_server latest f0bde03754eb 41 minutes ago 406 MB srv.world/fedora_httpd latest a461b4b0b704 45 minutes ago 452 MB registry.fedoraproject.org/fedora latest d81c91deec0d 11 days ago 208 MB k8s.gcr.io/pause 3.2 80d28bedfe5d 2 months ago 688 kB docker.io/library/registry 2 708bc6af7e5e 3 months ago 26.3 MB # 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 ae07178a143eb4af271669a08774b055bd96ec878216cf5118b1d63749d0f52d[root@dlp ~]# podman pod ls POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID fea26c02db58 test_pod2 Running 8 seconds ago 2 5f291b34376b[root@dlp ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ae07178a143e srv.world/nginx_server:latest /usr/sbin/nginx -... 21 seconds ago Up 21 seconds ago 0.0.0.0:80->80/tcp epic_galileo ..... .....[root@dlp ~]# podman run -dt --pod test_pod2 -e MYSQL_ROOT_PASSWORD=Password mariadb 6e9ddb57194403bed4c3c7a61032a2837c6a82011e6eb16b3b1222a52c4c7a34[root@dlp ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6e9ddb571944 docker.io/library/mariadb:latest mysqld 13 seconds ago Up 12 seconds ago 0.0.0.0:80->80/tcp sweet_noyce ae07178a143e srv.world/nginx_server:latest /usr/sbin/nginx -... 2 minutes ago Up 2 minutes ago 0.0.0.0:80->80/tcp epic_galileo 5f291b34376b k8s.gcr.io/pause:3.2 2 minutes ago Up 2 minutes ago 0.0.0.0:80->80/tcp fea26c02db58-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 | test_pod2 | +---------------+-----------+ |
Sponsored Link |