Fedora 37
Sponsored Link

Podman : Create Pods2022/11/22

 
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

463371b5eda663773754a7ac22a51277d21d3d9c921f2620cc187b1b711225ba

# show pods

[root@dlp ~]#
podman pod ls

POD ID        NAME        STATUS      CREATED         INFRA ID      # OF CONTAINERS
463371b5eda6  test-pod    Created     11 seconds ago  29b84520848a  1

# show details of pod

[root@dlp ~]#
podman pod inspect test-pod

{
     "Id": "463371b5eda663773754a7ac22a51277d21d3d9c921f2620cc187b1b711225ba",
     "Name": "test-pod",
     "Created": "2022-11-22T15:46:36.881319098+09: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_463371b5eda663773754a7ac22a51277d21d3d9c921f2620cc187b1b711225ba.slice",
     "CreateInfra": true,
     "InfraContainerID": "29b84520848a4ad42471822b96b48473ed8b947b300988e3fa7af8d8ca22d342",
     "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": "29b84520848a4ad42471822b96b48473ed8b947b300988e3fa7af8d8ca22d342",
               "Name": "463371b5eda6-infra",
               "State": "created"
          }
     ]
}

[root@dlp ~]#
podman images

REPOSITORY                         TAG               IMAGE ID      CREATED             SIZE
localhost/podman-pause             4.3.1-1668178887  9368de8f92c7  About a minute ago  1.09 MB
srv.world/iproute                  latest            ac96369ed105  14 minutes ago      402 MB
srv.world/fedora-nginx             latest            3e184c6f4609  About an hour ago   430 MB
srv.world/fedora-httpd             latest            87f2afc7b89d  About an hour ago   458 MB
docker.io/library/mariadb          latest            28ca9ca8e298  4 days ago          416 MB
registry.fedoraproject.org/fedora  latest            885d2b38b819  11 days ago         190 MB

# run container and add it to pod

[root@dlp ~]#
podman run -dt --pod test-pod srv.world/fedora-nginx

82b834680a214c0b7b8c08262950976a33522fe67eec2265a90985b6068b7a42

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                    COMMAND               CREATED             STATUS             PORTS                 NAMES
29b84520848a  localhost/podman-pause:4.3.1-1668178887                        About a minute ago  Up 11 seconds ago  0.0.0.0:8081->80/tcp  463371b5eda6-infra
82b834680a21  srv.world/fedora-nginx:latest            /usr/sbin/nginx -...  11 seconds ago      Up 11 seconds ago  0.0.0.0:8081->80/tcp  priceless_jepsen

# verify accesses

[root@dlp ~]#
curl localhost:8081

Podman Test on Nginx
# stop pod

[root@dlp ~]#
podman pod stop test-pod

463371b5eda663773754a7ac22a51277d21d3d9c921f2620cc187b1b711225ba

# remove pod (removed containers all)

[root@dlp ~]#
podman pod rm test-pod --force

463371b5eda663773754a7ac22a51277d21d3d9c921f2620cc187b1b711225ba
[2] It's possbile 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-1668178887  9368de8f92c7  3 minutes ago      1.09 MB
srv.world/iproute                  latest            ac96369ed105  16 minutes ago     402 MB
srv.world/fedora-nginx             latest            3e184c6f4609  About an hour ago  430 MB
srv.world/fedora-httpd             latest            87f2afc7b89d  About an hour ago  458 MB
docker.io/library/mariadb          latest            28ca9ca8e298  4 days ago         416 MB
registry.fedoraproject.org/fedora  latest            885d2b38b819  11 days ago        190 MB

# create a [test-pod2] pod and add [srv.world/fedora-nginx] container

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

9e3f690d5e7ba1a1d9dc6ad6bd67b46da61b4ff67313859052f4c020e55bb02e

[root@dlp ~]#
podman pod ls

POD ID        NAME        STATUS      CREATED         INFRA ID      # OF CONTAINERS
daff51fe9774  test-pod2   Running     12 seconds ago  89392d8be32c  2

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                    COMMAND               CREATED         STATUS             PORTS                                       NAMES
89392d8be32c  localhost/podman-pause:4.3.1-1668178887                        28 seconds ago  Up 28 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  daff51fe9774-infra
9e3f690d5e7b  srv.world/fedora-nginx:latest            /usr/sbin/nginx -...  28 seconds ago  Up 28 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  gifted_einstein

# 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

4ce57d8e308c2c8f475acc3eca6817ce1245763f5cc8ce5c5ab39e2215cf5ae2

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                    COMMAND               CREATED             STATUS                 PORTS                                       NAMES
89392d8be32c  localhost/podman-pause:4.3.1-1668178887                        About a minute ago  Up About a minute ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  daff51fe9774-infra
9e3f690d5e7b  srv.world/fedora-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  gifted_einstein
4ce57d8e308c  docker.io/library/mariadb:latest         mariadbd              10 seconds ago      Up 10 seconds ago      0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  stupefied_hawking

[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 |
+---------------+-----------+
Matched Content