Podman: A start point
In this post, I will show how to install the Podman container tool on RHEL8 based systems.
According to the definition at Podman official website,
Podman is a utility provided as part of the libpod library. It can be used to create and maintain containers. The following tutorial will teach you how to set up Podman and perform some basic commands.
Basic concepts before start
We could some differences between architectures according to the following image.
- Bare metal: Each app runs in a physical host with an Operating System, these apps need to share the same libraries and environment to run in the same host.
- Virtualization: Each app runs in a virtual machine running. We can see an abstraction of physical hardware.
- Containers: Each app runs in a container and this is an abstraction of the app layers.
Why replace Docker with Podman?
Docker was considered the main tool to run containers for most years. This scenario has changed with the standardization of containers by OCI.
Podman permits you to run, build and deploy applications using Open Container Initiative (OCI)-compatible containers and container images.
We could consider some good points here to use Podman :
- Daemonless: It does not require a daemon.
- Rootless: It lets you run containers as a non-root user.
- systemd: Podman runs containers with Systemd by default.
- Kubernetes transition: Podman can generate YAML’s to move to Kubernetes.
Docker scenario: The Docker daemon may cause some problems in the environment like a single point of failure and the daemon own all child processes for the running containers.
Podman scenario: Podman interacts with the Linux kernel to manage containers through the runC container runtime process instead of a daemon.
The following document explains why Redhat move from Docker to Podman:
https://www.redhat.com/en/blog/why-red-hat-investing-cri-o-and-podman
Environment
I am running my environment with RHEL8 OS with a RedHat developer subscription and the following resource:
1 VM with 4 Gbs RAM, 2 vcpus.
Create an account in the quay.io (image repository)
I recommend reading the following document about Developer and Smal Business Production subscriptions :
This document can be used for RHEL8 based systems too!
Installation
- Install the package
[root@podman01 ~]# dnf install podman
2. Check the podman version
[root@podman01 ~]# podman --version
podman version 2.0.5
3. Setup quay repository in /etc/containers/registries.conf file.
registries = ['registry.access.redhat.com', 'registry.redhat.io', 'docker.io' , 'quay.io']
4. Run command podman info
[root@podman01 ~]# sudo podman infohost:
arch: amd64
buildahVersion: 1.15.1
cgroupVersion: v1
conmon:
package: conmon-2.0.20-2.module+el8.3.0+8221+97165c3f.x86_64
path: /usr/bin/conmon
version: 'conmon version 2.0.20, commit: 77ce9fd1e61ea89bd6cdc621b07446dd9e80e5b6'
cpus: 2
distribution:
distribution: '"rhel"'
version: "8.3"
eventLogger: file
hostname: podman01.example.com
idMappings:
gidmap: null
uidmap: null
kernel: 4.18.0-240.el8.x86_64
linkmode: dynamic
memFree: 2501382144
memTotal: 3917524992
ociRuntime:
name: runc
package: runc-1.0.0-68.rc92.module+el8.3.0+8221+97165c3f.x86_64
path: /usr/bin/runc
version: 'runc version spec: 1.0.2-dev'
os: linux
remoteSocket:
path: /run/podman/podman.sock
rootless: false
slirp4netns:
executable: ""
package: ""
version: ""
swapFree: 2210394112
swapTotal: 2210394112
uptime: 49m 53.15s
registries:
search:
- registry.access.redhat.com
- registry.redhat.io
- docker.io
- quay.io
store:
configFile: /etc/containers/storage.conf
containerStore:
number: 0
paused: 0
running: 0
stopped: 0
graphDriverName: overlay
graphOptions:
overlay.mountopt: nodev,metacopy=on
graphRoot: /var/lib/containers/storage
graphStatus:
Backing Filesystem: xfs
Native Overlay Diff: "false"
Supports d_type: "true"
Using metacopy: "true"
imageStore:
number: 1
runRoot: /var/run/containers/storage
volumePath: /var/lib/containers/storage/volumes
version:
APIVersion: 1
Built: 1600877882
BuiltTime: Wed Sep 23 13:18:02 2020
GitCommit: ""
GoVersion: go1.14.7
OsArch: linux/amd64
Version: 2.0.5
Podman basic operations
In this practice, I will create a WordPress site and following the main operations to practice.
Sign into quay.io
[root@podman01 ~]# podman login quay.io
Username: fajlinuxblog
Password:!
Search images with CLI
[root@podman01 ~]# podman search apache
Let’s pull the wordpress image
[root@podman01 ~]# podman pull quay.io/bitnami/nginx
Show the images
[root@podman01 ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
quay.io/bitnami/nginx latest 91f438133f9c 19 hours ago 93.4 MB
Run a web container
[root@podman01 ~]# sudo podman run -d --name web1 -p 8082:80 quay.io/bitnami/nginx
Check the container process
[root@podman01 ~]# sudo podman ps
Execute bash to log into the container
[root@podman01 ~]# podman exec -it web1 /bin/bash
bash-4.2$
Check the container logs
[root@podman01 ~]# podman logs web1
nginx 19:51:09.05
nginx 19:51:09.05 Welcome to the Bitnami nginx container
nginx 19:51:09.05 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-nginx
nginx 19:51:09.05 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-nginx/issues
nginx 19:51:09.05
nginx 19:51:09.05 INFO ==> ** Starting NGINX setup **
nginx 19:51:09.06 INFO ==> Validating settings in NGINX_* env vars
nginx 19:51:09.07 INFO ==> Initializing NGINXnginx 19:51:09.07 INFO ==> ** NGINX setup finished! **
nginx 19:51:09.08 INFO ==> ** Starting NGINX **
Try the access of web server with http://<PODMAN HOST IP ADDRESS>:8082
I hope to write more about Podman and Kubernetes in the future!
That’s all folks!