CentOS Stream 8
Sponsored Link

Podman : Create Pods2021/03/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

7a3c15d84979c805bb9491e2b36ffba6f251f272c04aacc5644ce62a55bd941b

# show pods

[root@dlp ~]#
podman pod ls

POD ID        NAME      STATUS   CREATED         INFRA ID      # OF CONTAINERS
7a3c15d84979  test-pod  Created  13 seconds ago  9926f1baf5c9  1

# show details of pod

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

{
     "Id": "7a3c15d84979c805bb9491e2b36ffba6f251f272c04aacc5644ce62a55bd941b",
     "Name": "test-pod",
     "Created": "2021-03-18T18:36:38.993800681-06:00",
     "CreateCommand": [
          "podman",
          "pod",
          "create",
          "-p",
          "8081:80",
          "-n",
          "test-pod"
     ],
     "State": "Created",
     "Hostname": "test-pod",
     "CreateCgroup": true,
     "CgroupParent": "machine.slice",
     "CgroupPath": "machine.slice/machine-libpod_pod_7a3c15d84979c805bb9491e2b36ffba6f251f272c04aacc5644ce62a55bd941b.slice",
     "CreateInfra": true,
     "InfraContainerID": "9926f1baf5c9e46071255c256bd9c1f3156184bf8ac6d556fd18603ebf2778a4",
     "InfraConfig": {
          "PortBindings": {
               "80/tcp": [
     {
          "HostIp": "",
          "HostPort": "8081"
     }
]
          },
          "HostNetwork": false,
          "StaticIP": "",
          "StaticMAC": "",
          "NoManageResolvConf": false,
          "DNSServer": null,
          "DNSSearch": null,
          "DNSOption": null,
          "NoManageHosts": false,
          "HostAdd": null,
          "Networks": null,
          "NetworkOptions": null
     },
     "SharedNamespaces": [
          "ipc",
          "net",
          "uts"
     ],
     "NumContainers": 1,
     "Containers": [
          {
               "Id": "9926f1baf5c9e46071255c256bd9c1f3156184bf8ac6d556fd18603ebf2778a4",
               "Name": "7a3c15d84979-infra",
               "State": "configured"
          }
     ]
}

[root@dlp ~]#
podman images

REPOSITORY                  TAG     IMAGE ID      CREATED         SIZE
srv.world/centos-nginx      latest  3e52e21dc11c  28 seconds ago  298 MB
srv.world/centos-httpd      latest  10a26af7ba4d  17 hours ago    322 MB
docker.io/library/registry  2       5c4008a25e05  3 weeks ago     26.8 MB
registry.centos.org/centos  stream8 2f3766df23b6  3 months ago    217 MB
dlp.srv.world:5000/centos   latest  2f3766df23b6  3 months ago    217 MB
k8s.gcr.io/pause            3.2     80d28bedfe5d  13 months ago   688 kB

# run container and add it to pod

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

81537ff5425547a1d706d8742a94e508051da1d34defc400d50d51261fc1570b

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                   COMMAND               CREATED         STATUS             PORTS                 NAMES
9926f1baf5c9  k8s.gcr.io/pause:3.2                          4 minutes ago   Up 17 seconds ago  0.0.0.0:8081->80/tcp  7a3c15d84979-infra
81537ff54255  srv.world/centos-nginx  /usr/sbin/nginx -...  17 seconds ago  Up 17 seconds ago  0.0.0.0:8081->80/tcp  keen_wiles

# verify accesses

[root@dlp ~]#
curl localhost:8081

Podman Test on Nginx
# stop pod

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

d688dbff0b271ad2fbefbfdc9259509d8877572f95983bb3f2f6b57b253bc074

# remove pod (removed containers all)

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

7a3c15d84979c805bb9491e2b36ffba6f251f272c04aacc5644ce62a55bd941b
[2] It's possible to create Pod and add Container with one command.
[root@dlp ~]#
podman images

REPOSITORY                  TAG     IMAGE ID      CREATED        SIZE
srv.world/centos-nginx      latest  3e52e21dc11c  4 minutes ago  298 MB
srv.world/centos-httpd      latest  10a26af7ba4d  17 hours ago   322 MB
docker.io/library/mariadb   latest  e27cf5bc24fe  2 weeks ago    407 MB
docker.io/library/registry  2       5c4008a25e05  3 weeks ago    26.8 MB
registry.centos.org/centos  stream8 2f3766df23b6  3 months ago   217 MB
dlp.srv.world:5000/centos   latest  2f3766df23b6  3 months ago   217 MB
k8s.gcr.io/pause            3.2     80d28bedfe5d  13 months ago  688 kB

# create a [test_pod2] pod and add [srv.world/centos-nginx] container

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

7697eb77d2409e8a0848df6c2cee61da2ae35cac12c8fdead9ca861b365ca52c

[root@dlp ~]#
podman pod ls

POD ID        NAME       STATUS   CREATED        INFRA ID      # OF CONTAINERS
8ef88b1f9422  test-pod2  Running  8 seconds ago  e8050f6d7c52  2

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                   COMMAND               CREATED         STATUS             PORTS                                       NAMES
e8050f6d7c52  k8s.gcr.io/pause:3.2                          24 seconds ago  Up 24 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  8ef88b1f9422-infra
7697eb77d240  srv.world/centos-nginx  /usr/sbin/nginx -...  24 seconds ago  Up 24 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  zen_mclaren

# run [mariadb] container and add it to the [test-pod2]

[root@dlp ~]#
podman run -dt --pod test-pod2 -e MYSQL_ROOT_PASSWORD=Password mariadb

89a4f4b21cb9c79290e0f1aedfd9855ea16ed95c76c5dca73b5f159c41f84519

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                             COMMAND               CREATED        STATUS            PORTS                                       NAMES
e8050f6d7c52  k8s.gcr.io/pause:3.2                                    3 minutes ago  Up 3 minutes ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  8ef88b1f9422-infra
7697eb77d240  srv.world/centos-nginx            /usr/sbin/nginx -...  3 minutes ago  Up 3 minutes ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  zen_mclaren
89a4f4b21cb9  docker.io/library/mariadb:latest  mysqld                8 seconds ago  Up 9 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  tender_ramanujan

[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