Rocky_Linux_8
Sponsored Link

Podman : Create Pods2021/07/29

 
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

13562711fc936c7241b75cc17766f9806ccaab0ee85235de7a8cd65963250f7a

# show pods

[root@dlp ~]#
podman pod ls

POD ID        NAME      STATUS   CREATED         INFRA ID      # OF CONTAINERS
13562711fc93  test-pod  Created  12 seconds ago  03f90ef7525f  1

# show details of pod

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

{
     "Id": "13562711fc936c7241b75cc17766f9806ccaab0ee85235de7a8cd65963250f7a",
     "Name": "test-pod",
     "Created": "2021-07-29T16:28:41.770122093+09: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_13562711fc936c7241b75cc17766f9806ccaab0ee85235de7a8cd65963250f7a.slice",
     "CreateInfra": true,
     "InfraContainerID": "03f90ef7525fbaab5573af869c9810e82d20c0bc45b35caac73daaff75541625",
     "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": [
          "uts",
          "ipc",
          "net"
     ],
     "NumContainers": 1,
     "Containers": [
          {
               "Id": "03f90ef7525fbaab5573af869c9810e82d20c0bc45b35caac73daaff75541625",
               "Name": "13562711fc93-infra",
               "State": "configured"
          }
     ]
}

[root@dlp ~]#
podman images

REPOSITORY                             TAG     IMAGE ID      CREATED            SIZE
localhost/root_web                     latest  a5b8f841a624  24 minutes ago     340 MB
srv.world/rocky-nginx                  latest  b11bf176fd62  About an hour ago  340 MB
srv.world/rocky-httpd                  latest  5104875e9a87  About an hour ago  342 MB
docker.io/library/mariadb              latest  fd17f5776802  2 days ago         416 MB
registry.access.redhat.com/ubi8/pause  latest  330db2d74fc3  5 weeks ago        3.49 MB
docker.io/rockylinux/rockylinux        latest  333da17614b6  5 weeks ago        234 MB
docker.io/library/registry             2       1fd8e1b0bb7e  3 months ago       26.8 MB

# run container and add it to pod

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

494e63d0d139d49446a080ba43c73698c4ca353927b145228c36e0eb9d3d1cc4

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                         COMMAND               CREATED             STATUS            PORTS                 NAMES
03f90ef7525f  registry.access.redhat.com/ubi8/pause:latest                        About a minute ago  Up 7 seconds ago  0.0.0.0:8081->80/tcp  13562711fc93-infra
494e63d0d139  srv.world/rocky-nginx                         /usr/sbin/nginx -...  7 seconds ago       Up 7 seconds ago  0.0.0.0:8081->80/tcp  unruffled_tereshkova

# verify accesses

[root@dlp ~]#
curl localhost:8081

Podman Test on Nginx
# stop pod

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

13562711fc936c7241b75cc17766f9806ccaab0ee85235de7a8cd65963250f7a

# remove pod (removed containers all)

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

13562711fc936c7241b75cc17766f9806ccaab0ee85235de7a8cd65963250f7a
[2] It's possbile to create Pod and add Container with one command.
[root@dlp ~]#
podman images

REPOSITORY                             TAG     IMAGE ID      CREATED            SIZE
localhost/root_web                     latest  a5b8f841a624  25 minutes ago     340 MB
srv.world/rocky-nginx                  latest  b11bf176fd62  About an hour ago  340 MB
srv.world/rocky-httpd                  latest  5104875e9a87  About an hour ago  342 MB
docker.io/library/mariadb              latest  fd17f5776802  2 days ago         416 MB
registry.access.redhat.com/ubi8/pause  latest  330db2d74fc3  5 weeks ago        3.49 MB
docker.io/rockylinux/rockylinux        latest  333da17614b6  5 weeks ago        234 MB
docker.io/library/registry             2       1fd8e1b0bb7e  3 months ago       26.8 MB

# 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/rocky-nginx

728f04f6d7ca9d82a69e878b17f859e9ce567d49ae7abe07c61b645f0f6d9b7a

[root@dlp ~]#
podman pod ls

POD ID        NAME       STATUS   CREATED        INFRA ID      # OF CONTAINERS
502e2bb2f924  test-pod2  Running  7 seconds ago  eb00b01d9fb2  2

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                         COMMAND               CREATED         STATUS             PORTS                                       NAMES
eb00b01d9fb2  registry.access.redhat.com/ubi8/pause:latest                        17 seconds ago  Up 17 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  502e2bb2f924-infra
728f04f6d7ca  srv.world/rocky-nginx                         /usr/sbin/nginx -...  17 seconds ago  Up 17 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  epic_lehmann

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

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

1c83561172a11ea05440f7e438b223669db07f5da66ac2dcd4c4e59c084bce3d

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                                         COMMAND               CREATED         STATUS             PORTS                                       NAMES
eb00b01d9fb2  registry.access.redhat.com/ubi8/pause:latest                        49 seconds ago  Up 49 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  502e2bb2f924-infra
728f04f6d7ca  srv.world/rocky-nginx                         /usr/sbin/nginx -...  49 seconds ago  Up 49 seconds ago  0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  epic_lehmann
1c83561172a1  docker.io/library/mariadb:latest              mysqld                6 seconds ago   Up 6 seconds ago   0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp  optimistic_franklin

[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