Podman : Create Pods2021/08/28 |
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 01d10e5c8a5ab59a0cc11d297d3ee660ef689bfc3b4af94fec6dee7ce9259d00 # show pods root@dlp:~# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 01d10e5c8a5a test-pod Created 18 seconds ago 01547bd444b4 1 # show details of 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 # run container and add it to 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 # verify accesses root@dlp:~# curl localhost:8081 Podman Test on Nginx # stop pod root@dlp:~# podman pod stop test-pod 01d10e5c8a5ab59a0cc11d297d3ee660ef689bfc3b4af94fec6dee7ce9259d00 # remove pod (removed containers all) root@dlp:~# podman pod rm test-pod --force 01d10e5c8a5ab59a0cc11d297d3ee660ef689bfc3b4af94fec6dee7ce9259d00 |
[2] | It's possible to create Pod and add Container with one command. |
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 # create a [test_pod2] pod and add [srv.world/debian-nginx] container 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 # run [mariadb] container and add it to the [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 |