Fedora 40
Sponsored Link

Podman : Create Pods2024/05/03

 
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

e90986e6116193a3ab84c90d51a63eabb991696622899e1c04f483d70223cfd5

# show pods

[root@dlp ~]#
podman pod ls

POD ID        NAME        STATUS      CREATED         INFRA ID      # OF CONTAINERS
e90986e61161  test-pod    Created     15 seconds ago  74dd9de1cccf  1

# show details of pod

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

[
     {
          "Id": "e90986e6116193a3ab84c90d51a63eabb991696622899e1c04f483d70223cfd5",
          "Name": "test-pod",
          "Created": "2024-05-03T17:21:16.430892437+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_e90986e6116193a3ab84c90d51a63eabb991696622899e1c04f483d70223cfd5.slice",
          "CreateInfra": true,
          "InfraContainerID": "74dd9de1cccf8a8b7de83cff8083a4940f98a13e3c29e0bb63ded707454168b2",
          "InfraConfig": {
               "PortBindings": {
                    "80/tcp": [
                         {
                              "HostIp": "0.0.0.0",
                              "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": "74dd9de1cccf8a8b7de83cff8083a4940f98a13e3c29e0bb63ded707454168b2",
                    "Name": "e90986e61161-infra",
                    "State": "created"
               }
          ],
          "LockNumber": 10
     }
]

[root@dlp ~]#
podman images

REPOSITORY                         TAG               IMAGE ID      CREATED            SIZE
localhost/podman-pause             5.0.2-1713312000  93b49289d5db  2 minutes ago      742 kB
srv.world/iproute                  latest            dafe2df281ae  10 minutes ago     307 MB
localhost/root_web                 latest            53d5fa92aef2  About an hour ago  340 MB
srv.world/fedora-nginx             latest            cf5af4219b13  2 hours ago        340 MB
srv.world/fedora-httpd             latest            9d6d273370e2  2 hours ago        343 MB
dlp.srv.world:5000/fedora          my-registry       19f52f582331  3 hours ago        229 MB
registry.fedoraproject.org/fedora  latest            19f52f582331  3 hours ago        229 MB
docker.io/library/mariadb          latest            465bc4da7f09  2 months ago       411 MB

# run container and add it to pod

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

547cc61eb1b9342b71eebbaa7329f624b8e21e3ec38bb79901a294caa29aa3f4

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                    COMMAND               CREATED         STATUS         PORTS                 NAMES
74dd9de1cccf  localhost/podman-pause:5.0.2-1713312000                        3 minutes ago   Up 18 seconds  0.0.0.0:8081->80/tcp  e90986e61161-infra
547cc61eb1b9  srv.world/fedora-nginx:latest            /usr/sbin/nginx -...  17 seconds ago  Up 18 seconds  0.0.0.0:8081->80/tcp  bold_morse

# verify accesses

[root@dlp ~]#
curl localhost:8081

Podman Test on Nginx
# stop pod

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

e90986e6116193a3ab84c90d51a63eabb991696622899e1c04f483d70223cfd5

# remove pod (removed containers all)

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

e90986e6116193a3ab84c90d51a63eabb991696622899e1c04f483d70223cfd5
[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             5.0.2-1713312000  93b49289d5db  4 minutes ago      742 kB
srv.world/iproute                  latest            dafe2df281ae  12 minutes ago     307 MB
localhost/root_web                 latest            53d5fa92aef2  About an hour ago  340 MB
srv.world/fedora-nginx             latest            cf5af4219b13  2 hours ago        340 MB
srv.world/fedora-httpd             latest            9d6d273370e2  2 hours ago        343 MB
dlp.srv.world:5000/fedora          my-registry       19f52f582331  3 hours ago        229 MB
registry.fedoraproject.org/fedora  latest            19f52f582331  3 hours ago        229 MB
docker.io/library/mariadb          latest            465bc4da7f09  2 months ago       411 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

8dcab2aa83c608b2486b562fc55eb6ca39fabe676f494619cd4348a176c180db

[root@dlp ~]#
podman pod ls

POD ID        NAME        STATUS      CREATED         INFRA ID      # OF CONTAINERS
56f1b1035de2  test-pod2   Running     16 seconds ago  adef50b5e6aa  2

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                    COMMAND               CREATED         STATUS         PORTS                                       NAMES
adef50b5e6aa  localhost/podman-pause:5.0.2-1713312000                        41 seconds ago  Up 41 seconds  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  56f1b1035de2-infra
8dcab2aa83c6  srv.world/fedora-nginx:latest            /usr/sbin/nginx -...  41 seconds ago  Up 41 seconds  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  frosty_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

493f7d47fff1bc0802348ae033ae5758d37b8523dfe1792c879d1cdc95e4ee32

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                    COMMAND               CREATED             STATUS             PORTS                                       NAMES
adef50b5e6aa  localhost/podman-pause:5.0.2-1713312000                        About a minute ago  Up About a minute  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  56f1b1035de2-infra
8dcab2aa83c6  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  frosty_blackwell
493f7d47fff1  docker.io/library/mariadb:latest         mariadbd              29 seconds ago      Up 29 seconds      0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  recursing_lewin

[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