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
Verify there are no running or stopped containers:
podman ps -a
Check to see if there are images on the system:
podman images
Search for the latest NGINX container image:
podman search nginx | grep -i official
Check for
docker.io
underNAME
andOfficial build of Nginx.
underDESCRIPTION
.Copy the name of the official NGINX container image, then clear your screen.
Pull the NGINX container image:
podman pull <CONTAINER_IMAGE_NAME>
Clear your screen:
clear
Verify the image is on the system:
podman images
📝Run a Container Using the NGINX Container Image
Run a container using the NGINX container image:
podman run -d --name nginx-1 -p 8080:80 <CONTAINER_IMAGE_NAME>
Verify the container is running:
podman ps
Clear your screen:
clear
📝Verify the New Container Is Working
Verify that the web server is running:
curl localhost:8080
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