Ubuntu 22.04
Sponsored Link

Podman : पॉड्स बनाएं2023/09/04

 
Kubernetes जैसे पॉड्स बनाएं।
[1] एक पॉड बनाएं और उसमें एक कंटेनर जोड़ें।
# एक खाली पॉड बनाएं
# -p [bind port] -n [pod name]

root@dlp:~#
podman pod create -p 8081:80 -n test-pod

f20604e462ca2e68343776fa3150a8df08469aa3005b062adfdf5980da2e0421

# फली दिखाओ

root@dlp:~#
podman pod ls

POD ID        NAME        STATUS      CREATED        INFRA ID      # OF CONTAINERS
f20604e462ca  test-pod    Created     8 seconds ago  a4a38b154286  1

# पॉड का विवरण दिखाएं

root@dlp:~#
podman pod inspect test-pod

{
     "Id": "f20604e462ca2e68343776fa3150a8df08469aa3005b062adfdf5980da2e0421",
     "Name": "test-pod",
     "Created": "2022-04-28T07:02:13.638313303Z",
     "CreateCommand": [
          "podman",
          "pod",
          "create",
          "-p",
          "8081:80",
          "-n",
          "test-pod"
     ],
     "State": "Created",
     "Hostname": "",
     "CreateCgroup": true,
     "CgroupParent": "machine.slice",
     "CgroupPath": "machine.slice/machine-libpod_pod_f20604e462ca2e68343776fa3150a8df08469aa3005b062adfdf5980da2e0421.slice",
     "CreateInfra": true,
     "InfraContainerID": "a4a38b15428675bf5a917fe3bb8a8135c6d1901c0395767224afd4be1e1387ff",
     "InfraConfig": {
          "PortBindings": {
               "80/tcp": [
     {
          "HostIp": "",
          "HostPort": "8081"
     }
]
          },
          "HostNetwork": true,
          "StaticIP": "",
          "StaticMAC": "",
          "NoManageResolvConf": false,
          "DNSServer": null,
          "DNSSearch": null,
          "DNSOption": null,
          "NoManageHosts": false,
          "HostAdd": null,
          "Networks": null,
          "NetworkOptions": null,
          "pid_ns": "private",
          "userns": "host"
     },
     "SharedNamespaces": [
          "ipc",
          "net",
          "uts"
     ],
     "NumContainers": 1,
     "Containers": [
          {
               "Id": "a4a38b15428675bf5a917fe3bb8a8135c6d1901c0395767224afd4be1e1387ff",
               "Name": "f20604e462ca-infra",
               "State": "configured"
          }
     ]
}

root@dlp:~#
podman images

REPOSITORY                  TAG         IMAGE ID      CREATED            SIZE
srv.world/ubuntu-nginx      latest      00787fa1628b  About an hour ago  170 MB
srv.world/ubuntu-apache2    latest      c5d3a78bc38f  About an hour ago  224 MB
docker.io/library/mariadb   latest      7a1ace59b072  6 days ago         421 MB
docker.io/library/ubuntu    latest      3f4714ee068a  6 days ago         80.3 MB
docker.io/library/registry  2           2e200967d166  3 weeks ago        24.7 MB
k8s.gcr.io/pause            3.5         ed210e3e4a5b  13 months ago      690 kB

# कंटेनर चलाएं और इसे पॉड में जोड़ें

root@dlp:~#
podman run -dt --pod test-pod srv.world/ubuntu-nginx

eec3cc1b6e88857703d1f61542041d22a9317d6556e9c5a68caef02387531e8a

root@dlp:~#
podman ps

CONTAINER ID  IMAGE                          COMMAND               CREATED             STATUS            PORTS                 NAMES
a4a38b154286  k8s.gcr.io/pause:3.5                                 About a minute ago  Up 8 seconds ago  0.0.0.0:8081->80/tcp  f20604e462ca-infra
eec3cc1b6e88  srv.world/ubuntu-nginx:latest  /usr/sbin/nginx -...  8 seconds ago       Up 8 seconds ago  0.0.0.0:8081->80/tcp  exciting_bouman

# पहुंच सत्यापित करें

root@dlp:~#
curl localhost:8081

Podman Test on Nginx
# फली बंद करो

root@dlp:~#
podman pod stop test-pod

f20604e462ca2e68343776fa3150a8df08469aa3005b062adfdf5980da2e0421

# पॉड हटाएं (सभी कंटेनर हटा दिए गए)

root@dlp:~#
podman pod rm test-pod --force

f20604e462ca2e68343776fa3150a8df08469aa3005b062adfdf5980da2e0421
[2] एक कमांड से पॉड बनाना और कंटेनर जोड़ना संभव है।
root@dlp:~#
podman images

REPOSITORY                  TAG     IMAGE ID      CREATED        SIZE
srv.world/ubuntu-nginx      latest  37125087a75f  5 hours ago    216 MB
srv.world/ubuntu-apache2    latest  68a7269c5457  5 hours ago    260 MB
docker.io/library/ubuntu    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

# एक [test_pod2] पॉड बनाएं और [srv.world/ubuntu-nginx] कंटेनर जोड़ें

root@dlp:~#
podman run -dt --pod new:test-pod2 -p 80:80 -p 3306:3306 srv.world/ubuntu-nginx

63366e847dbff84e7c67961900624272f8762319876c44783144b86478c79063

root@dlp:~#
podman pod ls

POD ID        NAME        STATUS      CREATED         INFRA ID      # OF CONTAINERS
796f464a433c  test-pod2   Running     13 seconds ago  7c1c826b9808  2

root@dlp:~#
podman ps

CONTAINER ID  IMAGE                          COMMAND               CREATED         STATUS             PORTS                                       NAMES
7c1c826b9808  k8s.gcr.io/pause:3.5                                 26 seconds ago  Up 26 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  796f464a433c-infra
63366e847dbf  srv.world/ubuntu-nginx:latest  /usr/sbin/nginx -...  26 seconds ago  Up 26 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  nice_chaum

# [mariadb] कंटेनर चलाएँ और इसे [test-pod2] में जोड़ें

root@dlp:~#
podman run -dt --pod test-pod2 -e MYSQL_ROOT_PASSWORD=Password docker.io/library/mariadb

63c04b93b764120a7960c04244709bd601f192703206c3d6b49a7740bc38275f

root@dlp:~#
podman ps

CONTAINER ID  IMAGE                             COMMAND               CREATED         STATUS             PORTS                                       NAMES
7c1c826b9808  k8s.gcr.io/pause:3.5                                    59 seconds ago  Up 59 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  796f464a433c-infra
63366e847dbf  srv.world/ubuntu-nginx:latest     /usr/sbin/nginx -...  59 seconds ago  Up 59 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  nice_chaum
63c04b93b764  docker.io/library/mariadb:latest  mariadbd              6 seconds ago   Up 6 seconds ago   0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  focused_easley

root@dlp:~#
curl dlp.srv.world

Dockerfile Test on Nginx
root@dlp:~#
mysql -u root -p -h dlp.srv.world -e "show variables like 'hostname';"

Enter password:
+---------------+-----------+
| Variable_name | Value     |
+---------------+-----------+
| hostname      | test-pod2 |
+---------------+-----------+
मिलान सामग्री