OpenShift Hands-On Lab - Creating a Containerized Web Server

OpenShift Hands-On Lab - Creating a Containerized Web Server

Kubernetes Learning Path for Cloud and DevOps Engineers

📝Introduction

In this lab, we will pull an existing container image from a repository, start the container, and expose the web server port to the local host. After completing this lab you will know to search for an image, pull the image, and start up a running container by using Podman an open-source tool for developing, managing, and running containers on your Linux® systems.

These are the objectives of this lab:

  • Search for and Pull the NGINX Container Image

  • Run a Container Using the NGINX Container Image

  • Verify the New Container Is Working

📝Log in to the AWS Management Console

Using your credentials, make sure you're using the right Region. In my case, I am using AWS as my cloud provider and chose us-east-1. However, for this hands-on lab, you can select any cloud provider to create your Linux server VM (I am using a Red Hat Enterprise Linux 8.7 distro) and Podman 3.0.1 (Link to how to install Podman).

📌Note: You must create the AWS Access Key and AWS Secret Access Key and configure the AWS CLI in the terminal to use it.

You can use link1 and link2 for it.

📝Search for and Pull the NGINX Container Image

  1. Verify there are no running or stopped containers:

     podman ps -a
    
  2. Check to see if there are images on the system:

     podman images
    
  3. Search for the latest NGINX container image:

     podman search nginx | grep -i official
    
  4. Check for docker.io under NAME and Official build of Nginx. under DESCRIPTION.

  5. Copy the name of the official NGINX container image, then clear your screen.

  6. Pull the NGINX container image:

     podman pull <CONTAINER_IMAGE_NAME>
    
  7. Clear your screen:

     clear
    
  8. Verify the image is on the system:

     podman images
    

📝Run a Container Using the NGINX Container Image

  1. Run a container using the NGINX container image:

     podman run -d --name nginx-1 -p 8080:80 <CONTAINER_IMAGE_NAME>
    
  2. Verify the container is running:

     podman ps
    
  3. Clear your screen:

     clear
    

📝Verify the New Container Is Working

  1. Verify that the web server is running:

     curl localhost:8080
    
  2. To verify that the web server is running, enter the Public DNS hostname or Public IP address of the Cloud Server instance (provided in the Credentials section) in a web browser followed by :8080.

📌Note - At the end of each hands-on Lab, always clean up all previous resources created to avoid being charged if you used a Cloud Provider to provision them.

Congratulations — you have completed this hands-on lab covering the basics of pulling an existing container image from a repository, starting the container, and exposing the web server port to the local host by using Podman.

Thank you for reading. I hope you understood and learned something helpful from my blog.

Please follow me on CloudDevOpsToLearn and LinkedIn, franciscojblsouza