Podman is a Linux-native tool for deploying applications using Open Container Initiative (OCI) containers and container images. It supports multiple container image formats, including Docker images and OCI container images. Also, Podman supports managing pods, and groups of containers.

Podman is a daemon-less tool, running as a single binary command line without a service. It provides a command line similar to Docker, you can use an alias such as ‘alias docker=podman’.

In this guide, we will show you how to install and use Podman as a replacement for Docker Engine on an AlmaLinux 9 server. You will learn how to some basics usage of Podman for managing container applications. By completing this guide, you will have a better grasp of using Podman as container orchestration for your local development.

Prerequisites

To begin with this guide, you must have the following:

  • An AlmaLinux 9 server – This example uses a server with the hostname ‘AlmaLinux9‘.
  • A non-root user with sudo/root administrator privileges.

Installing Podman

Podman is a daemon less and open-source container orchestration for rapid development. Podman is Linux native application and provides a command line interface similar to Docker.

With Podman, you can find, run, share, and deploy applications using OCI (Open Containers Initiative) containers and container images.

On AlmaLinux, Podman is available by default on the AppStream repository, you can install it using the DNF package manager.

Run the following dnf command to install Podman on your AlmaLinux server.

sudo dnf install podman

Input y when prompted, then press ENTER.

<img alt="installing podman" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/1-install-podman.png64523cb4da7ed.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="481" loading="lazy" src="data:image/svg xml,” width=”750″>

Because the Podman is a daemon-less, you can just run it without starting any daemon.

Run the following command to check the Podman version and detailed information about your installation.

podman version

Below is an output of the current Podman version during this writing:

<img alt="checking podman version" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/2-check-podman-version.png64523cb510b5a.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="211" loading="lazy" src="data:image/svg xml,” width=”411″>

In addition, you can also verify details of Podman installation using the following command.

podman info

Running Podman as a non-root User

In this section, you will set up Podman for a non-root user. You will create a new user and ensure that the new non-root user can execute and run containers with Podman.

Run the following command to create a new user called ‘alice‘ and configure the password for it. Input a new password when prompted, then repeat.

sudo useradd -m -s /bin/bash alice

sudo passwd alice

Now, add the new user ‘alice‘ to the group ‘wheel‘. This allows the new user to execute ‘sudo‘ and become root.

sudo usermod -aG wheel alice

After that, run the following command to enable lingering for the user ‘alice’. This allows user ‘alice’ to run the container process for a long period, even when the user is logged out, the process will still be running.

sudo loginctl enable-linger alice

Next, log in as the new user ‘alice‘ using the command below.

su - alice

<img alt="create new user" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/3-create-user.png64523cb539fe6.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="298" loading="lazy" src="data:image/svg xml,” width=”578″>

Run the ‘podman‘ command below to run a new container with the image ‘hello-world‘.

podman run hello-world

If successful, you should get an output like this:

<img alt="running container hello-world" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/4-podman-run-hello-world.png64523cb561098.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="381" loading="lazy" src="data:image/svg xml,” width=”532″>

Lastly, run the following ‘podman’ command to verify the list of running and exited containers.

podman ps -a

If the configuration is successful, you should see the container with the base image ‘hello-world‘ with the status ‘Exited‘.

<img alt="checking the list of containers" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/5-checking-containers-exited.png64523cb57861c.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="79" loading="lazy" src="data:image/svg xml,” width=”750″>

Finding Container Images

By default, Podman will retrieve container images from multiple image registries, such as Redhat image registry, quay.io, and also DockerHub. You can add more container image registries to the configuration ‘/etc/containers/registries.conf’.

This example will be using DockerHub as a container registry, so let’s get started.

Run the following command to find new container images that contain ‘httpd‘.

podman search httpd

Below is an output you should receive on your terminal:

<img alt="searching container" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/6-search-images-podman.png64523cb5d86eb.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="635" loading="lazy" src="data:image/svg xml,” width=”750″>

You can also limit the output by using the ‘–limit‘ option like this.

podman search httpd --limit 3

This will show only the top three container images from each container image registry.

<img alt="finding images top 3" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/8-top-three-on-every-registry.png64523cb60dd35.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="227" loading="lazy" src="data:image/svg xml,” width=”750″>

Lastly, you can also use the ‘–filter‘ option like this.

podman search httpd --filter=is-official

This will show you only official container images.

<img alt="filter output" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/7-filter-output-podman-search.png64523cb62ef0f.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="121" loading="lazy" src="data:image/svg xml,” width=”578″>

Downloading Images

After you find the container images, the next step is to download the container images from registries.

Run the following command to download the image ‘httpd‘ with the tag ‘alpine‘.

podman pull httpd:alpine

Select the image registry that you want to use. This example will be using DockerHub.

<img alt="selecting container registry" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/9-select-registry.png64523cb653bbd.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="138" loading="lazy" src="data:image/svg xml,” width=”489″>

After the source is selected, the download process will begin.

<img alt="pull images" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/10-pull-images.png64523cb68429e.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="335" loading="lazy" src="data:image/svg xml,” width=”608″>

Once finished, run the following command to check available images on your AlmaLinux server.

podman images

At this point, if successful, you should get two container images, the image ‘hello-world‘ from quay.io and ‘httpd‘ from the DockerHub.

<img alt="checking list images" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/11-list-images.png64523cb69b4ff.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="139" loading="lazy" src="data:image/svg xml,” width=”688″>

Inspecting Images

Inspecting images is a powerful to get detailed information on how the container will start. On Podman and Docker, you can inspect images with the option ‘inspect’.

Run the following command to get detailed information about the image ‘httpd:alpine‘.

podman inspect docker.io/library/httpd:alpine

This will show you detailed information about the images, such as the date created, size, default working directory, start command, exposed port, and many more.

<img alt="detailed image" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/12-detailed-images.png64523cb6f1c9c.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="483" loading="lazy" src="data:image/svg xml,” width=”750″>

You can also specify which part you want to check using the additional parameter like this.

podman inspect --format "size: {{.Size}}" docker.io/library/httpd:alpine

podman inspect --format "ports: {{.Config.ExposedPorts}}" docker.io/library/httpd:alpine

podman inspect --format "workdir: {{.Config.WorkingDir}}" docker.io/library/httpd:alpine

This will show you the size of the image, the default exposed port, and the default working directory.

<img alt="inspecting image" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/13-inspect-images.png64523cb72dc26.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="140" loading="lazy" src="data:image/svg xml,” width=”750″>

Running Container

In this section, you will learn how to run the container with Podman.

Enter the following command to run a new container called ‘httpd’, expose the port 8080 on the host machine, and use the image ‘httpd:alpine‘. Also, the parameter ‘–rm‘, will automatically remove the container upon stopping the container.

podman run -it --rm -d -p 8080:80 --name httpd docker.io/library/httpd:alpine

If successful, you should get the random string and number of the new container id.

Check the running container using the following command. You should get the container ‘httpd‘ with the status ‘Up‘ and use port 8080 on the host machine.

podman ps

<img alt="running container" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/14-run-container.png64523cb75b48d.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="127" loading="lazy" src="data:image/svg xml,” width=”750″>

Next, you can check the container ‘httpd’ using the curl command below. Be sure to replace the IP address in the below example with your server IP address.

curl http://192.168.5.20:8080/

If successful, you should get an output like this:

<img alt="access container" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/15-access-container.png64523cb77da00.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="119" loading="lazy" src="data:image/svg xml,” width=”511″>

Moreover, you can also access the ‘httpd’ container via the web browser. Open your web browser and visit the server IP addresses followed by the container port 8080 (i.e: http://192.168.5.20:8080/).

If successful, you should get the default index.html page from the container ‘httpd‘ like this:

<img alt="accessing container" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/16-accessconainer.png64523cb7a72ef.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="129" loading="lazy" src="data:image/svg xml,” width=”499″>

Checking Logs Container

With the container ‘httpd’ up and running, now you will be checking the logs from the container.  Knowing this is useful for debugging your applications.

To show all logs from the container ‘httpd‘, run the following command.

podman logs httpd

This is an example of logs from the container ‘httpd’.

<img alt="checking logs container" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/17-podman-logs.png64523cb7e07c2.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="113" loading="lazy" src="data:image/svg xml,” width=”750″>

Next, you can reduce the log output using the ‘–tail’ parameter like this.

podman logs --tail 20 httpd

In this example, the parameter ‘tail 20‘ will show you the latest 20 lines of logs from container ‘httpd‘.

Stopping Container

Now, if you want to stop the container, simply run the `podman stop`.

Run the following command to stop the container ‘httpd‘.

podman stop httpd

Once the container ‘httpd‘ stopped, run the command below to check the list of available containers on your system.

podman ps

podman ps -a

The container ‘httpd‘ is automatically deleted after the container is stopped. This is because you run the container with the parameter ‘–rm’.

<img alt="stopping container" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/18-stop-conmtainer.png64523cb8205b1.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="145" loading="lazy" src="data:image/svg xml,” width=”750″>

Running Container with Custom Volume

In this example, you will run a new container with custom volume. This will mount the local directory on the host machine to the container.

Create a new ‘data‘ directory within the user alice home directory. Then create a new ‘index.html file inside the ‘data‘ directory using the nano editor.

mkdir -p ~/data/

nano ~/data/index.html

Insert the following HTML script.







 

  Welcome to Container Nginx





 

Hello from httpd container - Managed with Podman





Save and close the file.

Now, execute the following command to run a new container ‘httpd’ with the custom volume of the ‘data‘ directory, which will be mounted to the ‘/usr/local/apache2/htdocs‘ directory on the container.

podman run --privileged=true -it --rm -d -p 8080:80 --name httpd -v ~/data:/usr/local/apache2/htdocs docker.io/library/httpd:alpine

In addition, this container is running with an additional parameter ‘–privileged=true‘. This is for testing, and yet still the container will be run as a user ‘alice‘ and not the root user. Get more information about privileged flags on Podman.

Next, run the following command to check the running container on your system.

podman ps

If successful, you should see the new container ‘httpd‘ with the status ‘Up‘ and exposed port 8080 on the host machine.

<img alt="run container custom volumes" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/19-run-container-custom-volume.png64523cb853290.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="102" loading="lazy" src="data:image/svg xml,” width=”750″>

Run the curl command below to verify the new container ‘httpd‘.

curl http://192.168.5.21:8080/

You should get an output of the index.html script that you created earlier.

<img alt="accessing container" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/20-access-container.png64523cb8830a4.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="283" loading="lazy" src="data:image/svg xml,” width=”598″>

As from the web browser on http://192.168.5.21:8080/, you should be displayed the custom page like this:

<img alt="access container" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/21-access-container.png64523cb8a8fa8.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="157" loading="lazy" src="data:image/svg xml,” width=”659″>

Logging In to Container

With the ‘httpd‘ container running, you can access the container via shell by utilizing the ‘podman exec‘ command.

Log in to the container ‘httpd‘ using the following command. This will execute the ‘/bin/sh‘ shell on the container ‘httpd‘ and attached it to your current session.

podman exec -it httpd /bin/sh

Once logged in, you should be in the directory ‘WorkingDir‘. In his example, the default WorkingDir is the ‘/usr/local/apache2‘ directory.

Now run the following command on the container ‘httpd‘. Check the current user, the local IP address of the container, and the default gateway for the container.

id

ip a

route -n

You may have an output with a different IP address and gateway, but should be similar to this:

<img alt="accessing container" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/22-acess-container-shell.png64523cb8e86d2.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="560" loading="lazy" src="data:image/svg xml,” width=”750″>

Running and Managing Pod

In Podman, you can create and run Pod. The pod is a wrapper for containers, which means multiple containers can run on a single Pod. As in Kubernetes, Pod is the smallest entity where your application is running.

With Podman, you can create and run Pod, even without Kubernetes.

Run the following command to create a new pod httpdTest with the image ‘httpd:alpine‘ and expose port 9090 on the host machine.

podman run -dt --pod new:httpdTest -p 9090:80 docker.io/library/httpd:alpine

If successful, you should get the random string and number of Pod id.

Now run the following command to check the running Pod on your system.

podman pod ls

You should see the Pod ‘httpdTest‘ with the status ‘Running‘ and 2 containers.

<img alt="create pod" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/23-create-check_pod.png64523cb921bcc.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="165" loading="lazy" src="data:image/svg xml,” width=”750″>

You can now utilize the ‘inspect‘ option on the pod like this.

podman pod inspect httpdTest

You should get detailed information about the pod httpdTest.

<img alt="podman inspect pod" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/24-podman-pod-inspect.png64523cb97ede9.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="618" loading="lazy" src="data:image/svg xml,” width=”750″>

You can also check the number of containers that run within the pods including the names of containers using the following command.

podman pod inspect --format="containers: {{.NumContainers}}" httpdTest

podman pod inspect --format "{{.Containers}}" httpdTest

You will get an output like this:

<img alt="inspecting pod" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/05/echo/25-inspect-pod.png64523cb9a7607.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="84" loading="lazy" src="data:image/svg xml,” width=”750″>

Lastly, run the following command to access the pod httpdTest, which is running on port 9090 on the host machine. If successful, you should get the default index.html page containers that run on pod httpdTest.

curl http://192.168.5.21:9090/

Conclusion

Congratulation! You have now installed Podman on AlmaLinux 9. You have also learned the basic usage of Podman for managing images and containers. Furthermore, you have also learned how to create and run Pod with Podman.