Steps for configuring Apache HTTP WebServer and Python on the top of Docker Container

I am using RHEL-8(Redhat Enterprise Linux) as my Base OS.
Steps 1:- Add the URL of the repository for downloading.
Firstly, we need to put the url, from where we have to download docker image. It should be inside the yum repo. Use command cd /etc/yum.repos.d/
to go inside the folder. This command cat <your-repo-name>.repo
will read the file. Add this url in the given format to your repository.

Step 2:-Start docker service and pull image from the repository and execute it.
Start docker using command systemctl start docker
Pull image from the repository using docker pull centos:latest
. By using this docker images
command we can get list all the container images that are present in our system.

Before executing docker run -i -t --name webserver1 centos:latest
we can see that we are in baseOS and afterwards in container. This command is use to launch a container.

Step 3:- Install apache webserver and create a WebPage
Use yum install httpd
for installing apache webserver in container. Puty
when it asks for permission while installing.

After successful installation, it’s time to create a webpage. Create a webpage either using gedit or vi editor. Here I am using vi. We need to create your page inside /var/www/html/ folder . It is a by-default folder , we can change it too. But for now I am using the given one.

The data written in this file will be displayed on the webpage.

Step 4:- Start the httpd service and check the webpage
We usually use the command systemctl start httpd
but here we can’t use that, because this command is not supported in container world. We have another command for starting the service /usr/sbin/httpd
.

For checking we can use curl command , so we need to know the ip address of this OS. We can’t use ifconfig
command directly, for this first we need to install net-tool using yum install net-tools
.

Now check the ip address using ifconfig
command.

You can curl from the same OS or either use base OS for checking the webpage. Use command curl <ip-address>
.

Successfully Executed! You can we the actual page from web browser.
Step 5:- Installation of Python on Container OS
Put yum install python3
command on command line.

Check whether it is installed

That is it! We have successfully configured Apache Webserver and Python on the Container OS.