🔰Configuring httpd webserver & Setting up Python Interpreter and running Python Code on Docker Container🔰

Let’s understand few concepts related to our task :
What is Docker & Why is Docker needed?
Docker is a containerization platform that packages your application and all its dependencies together in the form of a docker container to ensure that your application works seamlessly in any environment.
What is Container ? Docker Container is a standardized unit which can be created on the fly to deploy a particular application or environment. It could be an Ubuntu container, CentOs container, etc. to full-fill the requirement from an operating system point of view.
What is the use of Apache httpd server?
Apache HTTPD is an HTTP server daemon produced by the Apache Foundation. It is a piece of software that listens for network requests (which are expressed using the Hypertext Transfer Protocol) and responds to them. It is open source and many entities use it to host their websites.
Now it is good to go as you know some terms related to the task :
ARTH — Task 7 👨🏻💻
Task Description 📄
🌀 7.2: Docker Task
🔅Configuring HTTPD Server on Docker Container
🔅Setting up Python Interpreter and running Python Code on Docker Container
👉🏻Lets get started…😃
(Here I am using rhel-8 Linux OS in my VM)
First thing we need is to install the docker container in our rhel-8 OS. To install it using yum we need to first configure yum in our system and also create .repo for the docker.
✔️Go to yum configuration file /etc/yum.repos.d/
✔️create docker.repo file here


After Configuring yum with docker repo.
We can ask yum do we have any docker-ce to install in our system.
✔️Command for this is :
# yum list docker-ce

So now it is available.
✔️To install docker-ce command is :
# yum install docker-ce --nobest

After we have successfully installed docker in our system. we have to start its service to use it.
🎯Step-1: Start The Docker Service
# systemctl start docker
✔️To check the status we have a command :
# systemctl status docker

🎯Step-2: Pull the Docker Image
To launch any isolated container we must have an image downloaded on our local system. Here I am pull CentOS image from docker hub.
✔️Command to pull an image :
# docker pull centos
🎯Step-3: Launch the Docker Container
# docker run -it --name webserver centos:latest

ifconfig command doesn’t work here. So we can ask yum that which software provides us ifconfig command :
# yum whatprovides ifconfig

✔️So we need to install the net-tools software to use ifconfig command.

After we have installed net-tools we can run ifconfig command to know our IP address.

Here my IP is 172.17.0.2
🔰To Configure Apache httpd webserver on docker container follow certain steps :
✔️Install httpd software
✔️Put the webpages in /var/www/html
✔️Start the Service
🎯Step-4: Install httpd software
Here Before installing make sure to stop firewall in Base OS. In rhel-8 to stop firewall we use systemctl stop firewalld command.
To install httpd software, run yum install httpd command inside the docker container.

🎯Step-5: Navigate to /var/www/html
In this directory we have to put the webpages created by us. Here I have created one webpage called web.html

🎯Step-6: Start the HTTPD Service
Normally to start the service we always use systemctl start httpd command. But in docker container by-default systemctl command doesn’t work. Here to start the service we use /usr/sbin/httpd

✔️To check that we have successfully started the service, we can run the command #netstat -tnlp if it shows port 80 then the service is started.
🎯Step-7: Access the webpage in Browser
Now we can access the webpage from our browser. Syntax is IP/filename.html
Here in my case my IP is 172.17.0.2 and file is web.html

Done✔!!
🔰Setting up Python Interpreter and running Python Code on Docker Container
To setup Python Interpreter we have to install python3 in our system. Command is :
# yum install python3

So Python 3 is successfully installed in our Docker Container, Now we can run any python code here.

That’s All! TASK COMPLETED👨🏻💻
Thanks for reading !!!😊✨