Podman : Create Pods2023/06/21 |
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 20889920c2fc33fd8fc73cafdf98d23d069b4e33654ca247c9a84fbfd90e4ef1 # show pods root@dlp:~# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 20889920c2fc test-pod Created 14 seconds ago 89a87cf6104a 1 # show details of pod root@dlp:~# podman pod inspect test-pod { "Id": "20889920c2fc33fd8fc73cafdf98d23d069b4e33654ca247c9a84fbfd90e4ef1", "Name": "test-pod", "Created": "2023-06-20T19:33:28.99473824-05:00", "CreateCommand": [ "podman", "pod", "create", "-p", "8081:80", "-n", "test-pod" ], "ExitPolicy": "continue", "State": "Created", "Hostname": "", "CreateCgroup": true, "CgroupParent": "machine.slice", "CgroupPath": "machine.slice/machine-libpod_pod_20889920c2fc33fd8fc73cafdf98d23d069b4e33654ca247c9a84fbfd90e4ef1.slice", "CreateInfra": true, "InfraContainerID": "89a87cf6104aabe45e703c43b7ca981f854e49eb16cbd1f335af527f3f1b2c9b", "InfraConfig": { "PortBindings": { "80/tcp": [ { "HostIp": "", "HostPort": "8081" } ] }, "HostNetwork": false, "StaticIP": "", "StaticMAC": "", "NoManageResolvConf": false, "DNSServer": null, "DNSSearch": null, "DNSOption": null, "NoManageHosts": false, "HostAdd": null, "Networks": [ "podman" ], "NetworkOptions": null, "pid_ns": "private", "userns": "host", "uts_ns": "private" }, "SharedNamespaces": [ "ipc", "net", "uts" ], "NumContainers": 1, "Containers": [ { "Id": "89a87cf6104aabe45e703c43b7ca981f854e49eb16cbd1f335af527f3f1b2c9b", "Name": "20889920c2fc-infra", "State": "created" } ] }root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 4.3.1-0 27bd47a0cfe1 About a minute ago 776 kB localhost/root_web latest 95ff1ec2c79f 7 minutes ago 158 MB srv.world/iproute latest e5a651fe23a6 20 minutes ago 157 MB srv.world/debian-nginx latest e2938e55cf7c 50 minutes ago 158 MB srv.world/debian-apache2 latest f047c6f28c56 57 minutes ago 260 MB docker.io/library/mariadb latest 99833200524a 4 days ago 410 MB docker.io/library/registry 2 4bb5ea59f8e0 5 days ago 24.6 MB docker.io/library/debian latest 49081a1edb0b 8 days ago 121 MB # run container and add it to pod root@dlp:~# podman run -dt --pod test-pod srv.world/debian-nginx 3b83a201ea392b46777e7481eed9831ec8e3f261685946aa2ab7f0aab3af402aroot@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 89a87cf6104a localhost/podman-pause:4.3.1-0 About a minute ago Up 10 seconds ago 0.0.0.0:8081->80/tcp 20889920c2fc-infra 3b83a201ea39 srv.world/debian-nginx:latest /usr/sbin/nginx -... 9 seconds ago Up 10 seconds ago 0.0.0.0:8081->80/tcp sweet_dijkstra # verify accesses root@dlp:~# curl localhost:8081 Podman Test on Nginx # stop pod root@dlp:~# podman pod stop test-pod 20889920c2fc33fd8fc73cafdf98d23d069b4e33654ca247c9a84fbfd90e4ef1 # remove pod (removed containers all) root@dlp:~# podman pod rm test-pod --force 20889920c2fc33fd8fc73cafdf98d23d069b4e33654ca247c9a84fbfd90e4ef1 |
[2] | It's possible to create Pod and add Container with one command. |
root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 4.3.1-0 27bd47a0cfe1 2 minutes ago 776 kB localhost/root_web latest 95ff1ec2c79f 8 minutes ago 158 MB srv.world/iproute latest e5a651fe23a6 22 minutes ago 157 MB srv.world/debian-nginx latest e2938e55cf7c 52 minutes ago 158 MB srv.world/debian-apache2 latest f047c6f28c56 59 minutes ago 260 MB docker.io/library/mariadb latest 99833200524a 4 days ago 410 MB docker.io/library/registry 2 4bb5ea59f8e0 5 days ago 24.6 MB docker.io/library/debian latest 49081a1edb0b 8 days ago 121 MB # 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 8aef8c0efd44a4401341fac197e8d6bda1be3dfb49fbcaab7a3b2ee19b5a62d5root@dlp:~# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 598975654d31 test-pod2 Running 13 seconds ago f2ed58888a2f 2root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f2ed58888a2f localhost/podman-pause:4.3.1-0 31 seconds ago Up 32 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 598975654d31-infra 8aef8c0efd44 srv.world/debian-nginx:latest /usr/sbin/nginx -... 31 seconds ago Up 32 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp sad_blackwell # 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 0e6342196221de2a74c7a5f40e754846717d9e6aede58e12cdef7f100db08278root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f2ed58888a2f localhost/podman-pause:4.3.1-0 About a minute ago Up About a minute ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 598975654d31-infra 8aef8c0efd44 srv.world/debian-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 sad_blackwell 0e6342196221 docker.io/library/mariadb:latest mariadbd 12 seconds ago Up 13 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp friendly_yalow
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 |
|