Running the Container with Podman

In this section, I walk through running a container with Podman, including pulling the NGINX container, verifying images, and interacting with the container.

What if I Couldn't Install Podman?

If I couldn’t install Podman on my system, I found a solution on Red Hat’s interactive labs: Red Hat Interactive Labs.

Listing Local Images

To list all images in the local storage, I typed:

podman images

This gave me the output shown here:

Podman Images Output
Running NGINX with Podman

I wanted to run NGINX, a popular web server for static websites. Running it in a container allows me to test it without installing it directly on my system.

To pull the NGINX image, I used the following command:

podman pull nginx

This command fetches the NGINX image from a container registry, such as Docker Hub, and downloads it to my local machine. Podman prepares it for use in a container.

When I ran the podman pull nginx command, I saw several options for where to pull the image from:

Podman asked me to choose an image with the prompt: "Please select an image:"

I selected the image from Docker Hub: docker.io/library/nginx:latest, and Podman began the pull process.

The progress was shown as "Copying blob," indicating parts of the image being downloaded. Once complete, Podman finished by writing the image’s manifest to my system. Now, the image was ready for use.

Pulling NGINX Image Step 1
Pulling NGINX Image Step 2
Verifying Available Images

After pulling the image, I used the command:

podman images

This listed the images on my system:

Now, I had two images:

Podman Images List
Running the NGINX Container

Next, I wanted to run the NGINX container. I executed the command:

podman run -d --name my-nginx-container -p 8080:80 docker.io/library/nginx:latest

I then ran podman ps to confirm that the container was running. The result was shown here:

Running NGINX Container
Verifying the Web Server

I checked if the NGINX container was working by running:

curl http://localhost:8080

I saw the default NGINX welcome page, confirming the server was up and running. To customize it, I would need to replace the default content with my own files. This result is shown here:

NGINX Default Page
Downloading the BBC Homepage

Next, I wanted to download a webpage. Using curl, I fetched the HTML of the BBC homepage:

curl -o /root/bbc_homepage.html https://www.bbc.com/

This saved the HTML as bbc_homepage.html in the /root directory. I verified the download by listing the files in /root with the ls command, shown here:

Downloading BBC Homepage
Listing Files in /root

To confirm the file's content, I used the cat command:

cat /root/bbc_homepage.html

This displayed the HTML content, as shown here:

Viewing HTML Content
Analyzing the HTML File

I could use tools like grep or awk to extract specific data from the downloaded HTML. For example, to extract all the links, I ran:

grep -oP '(?<=href=")[^"]+' /root/bbc_homepage.html

This command found and listed all the links in the HTML, shown here:

Extracting Links from HTML

This is how I set up and ran an NGINX container using Podman, pulled a webpage, and analyzed its content.