Fedora 39
Sponsored Link

Podman : Create Pods2023/11/16

 
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

d870844b8abcfd648e7bbc497f17d73fb27823d1cde0ea741ace95c8a925c0a8

# show pods

[root@dlp ~]#
podman pod ls

POD ID        NAME        STATUS      CREATED         INFRA ID      # OF CONTAINERS
d870844b8abc  test-pod    Created     14 seconds ago  39ff6534b88d  1

# show details of pod

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

{
     "Id": "d870844b8abcfd648e7bbc497f17d73fb27823d1cde0ea741ace95c8a925c0a8",
     "Name": "test-pod",
     "Created": "2023-11-16T10:27:29.475456535+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_d870844b8abcfd648e7bbc497f17d73fb27823d1cde0ea741ace95c8a925c0a8.slice",
     "CreateInfra": true,
     "InfraContainerID": "39ff6534b88dd37214ce55c0e4976887a215a6116b839274a1a422112db3cee9",
     "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": [
          "uts",
          "ipc",
          "net"
     ],
     "NumContainers": 1,
     "Containers": [
          {
               "Id": "39ff6534b88dd37214ce55c0e4976887a215a6116b839274a1a422112db3cee9",
               "Name": "d870844b8abc-infra",
               "State": "created"
          }
     ],
     "LockNumber": 12
}

[root@dlp ~]#
podman images

REPOSITORY                         TAG               IMAGE ID      CREATED             SIZE
localhost/podman-pause             4.7.2-1698762721  cb1af0765d22  About a minute ago  1.14 MB
srv.world/iproute                  latest            b2ff20987c53  8 minutes ago       417 MB
localhost/root_web                 latest            e1fc63ab5511  35 minutes ago      447 MB
srv.world/fedora-nginx             latest            6a43f18a8fc3  About an hour ago   447 MB
srv.world/fedora-httpd             latest            43a608e50bc8  About an hour ago   459 MB
registry.fedoraproject.org/fedora  latest            ec546109f822  8 days ago          183 MB
dlp.srv.world:5000/fedora          my-registry       ec546109f822  8 days ago          183 MB
docker.io/library/mariadb          latest            f35870862d64  4 weeks ago         410 MB

# run container and add it to pod

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

06faa591df074834f59b25bec9abac8a697f1f29ec0e058260c59f10ce2cb726

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                    COMMAND               CREATED             STATUS         PORTS                 NAMES
39ff6534b88d  localhost/podman-pause:4.7.2-1698762721                        About a minute ago  Up 14 seconds  0.0.0.0:8081->80/tcp  d870844b8abc-infra
06faa591df07  srv.world/fedora-nginx:latest            /usr/sbin/nginx -...  14 seconds ago      Up 14 seconds  0.0.0.0:8081->80/tcp  elated_jemison

# verify accesses

[root@dlp ~]#
curl localhost:8081

Podman Test on Nginx
# stop pod

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

d870844b8abcfd648e7bbc497f17d73fb27823d1cde0ea741ace95c8a925c0a8

# remove pod (removed containers all)

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

d870844b8abcfd648e7bbc497f17d73fb27823d1cde0ea741ace95c8a925c0a8
[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.7.2-1698762721  cb1af0765d22  3 minutes ago      1.14 MB
srv.world/iproute                  latest            b2ff20987c53  11 minutes ago     417 MB
localhost/root_web                 latest            e1fc63ab5511  38 minutes ago     447 MB
srv.world/fedora-nginx             latest            6a43f18a8fc3  About an hour ago  447 MB
srv.world/fedora-httpd             latest            43a608e50bc8  About an hour ago  459 MB
registry.fedoraproject.org/fedora  latest            ec546109f822  8 days ago         183 MB
dlp.srv.world:5000/fedora          my-registry       ec546109f822  8 days ago         183 MB
docker.io/library/mariadb          latest            f35870862d64  4 weeks ago        410 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

03f07451c154610b7ffe657dce5189f8c2917ef5f06abf877b31e7ac56f71589

[root@dlp ~]#
podman pod ls

POD ID        NAME        STATUS      CREATED         INFRA ID      # OF CONTAINERS
474a1332078e  test-pod2   Running     13 seconds ago  988d3b145f27  2

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                    COMMAND               CREATED         STATUS         PORTS                                       NAMES
988d3b145f27  localhost/podman-pause:4.7.2-1698762721                        35 seconds ago  Up 36 seconds  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  474a1332078e-infra
03f07451c154  srv.world/fedora-nginx:latest            /usr/sbin/nginx -...  35 seconds ago  Up 36 seconds  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  vibrant_benz

# 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

67ae261959a98a78ccd0d66cd69ed47374fb378843a70cfb17b41ebc1b203907

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                    COMMAND               CREATED             STATUS             PORTS                                       NAMES
988d3b145f27  localhost/podman-pause:4.7.2-1698762721                        About a minute ago  Up About a minute  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  474a1332078e-infra
03f07451c154  srv.world/fedora-nginx:latest            /usr/sbin/nginx -...  About a minute ago  Up About a minute  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  vibrant_benz
67ae261959a9  docker.io/library/mariadb:latest         mariadbd              19 seconds ago      Up 19 seconds      0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  upbeat_galois

[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