Configuring HTTPD Server and Setting up Python Interpreter and running Python Code on Docker Container

Lalita Sharma
3 min readNov 12, 2020

--

→ DEVOPS is one Technology ; Docker is a part of Devops ←

Hello Connections!!😃

In this article, we will going to learn about Docker🐋 and one of its application.

🌀 Task-Description:-

🔅Configuring HTTPD Server on Docker Container.

🔅Setting up Python Interpreter and running Python Code on Docker Container.

Let’s learn some basics:-

♦️ What is DOCKER?

Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. Docker has a capability to launch OS in 1 second which is called as docker container. It is highly efficient with low latency and high speed. Here, Containerization is a technology and docker is one of its highly used product.

♦️ What is WEBSERVER?

A Web-Server delivers content for a website to a client that requests it, like a web browser. The HTTP server is a product of Apache Community. The main job of a web server is to display website content through storing, processing and delivering webpages to users.

✳️So let’s perform the Task -1

🔅Configuring HTTPD Server on Docker Container.

1.) Install Docker

#yum install docker-ce --nobest

2.) Check Docker version

#docker version

3.) Start the docker service and Check status

#systemctl start docker
#systemctl status docker

4.)Before launch any OS, required OS image for that

#docker pull <imageName>:<version>
#docker pull centos:7

5.) Check docker images

#docker images

6.)Launch a docker container

#docker run -i -t --name <Enter any Container name> <os image>:<version>#docker run -i -t --name WebServer centos:7

7.)Install HTTPD software

#yum install httpd

>>Gives error‼️

⚡Try to start httpd service by using command:-

#systemctl start httpd

>>Again gives error, “systemctl” doesn’t work in docker container‼️

⚡In order, To solve this error run the above service start and status commads in base OS-RHEL8 , it gives you path → “/usr/sbin/httpd” , so, in docker container, we directly give this path from where software has configured or come. You can also use ‘#which httpd’ command inside docker container to see the path.

# /usr/sbin/httpd

Now, the httpd service has been started🔥.

8.) Create one html file inside document root directory: /var/www/html and write some html code

# cd /var/www/html/
# vi webserver.html //Create one html file and write some code inside it
# ls //list all files

9.) Check the IP-Address of docker container

To check this, use #ifconfig command but it gives error like command not found‼️. Now, To solve this error, we know every command comes from a software (or package), so by using yum , we can find out this:

#yum whatprovides ifconfig

⚡Then, it shows one package i.e. net-tools, install this software using command:

#yum install net-tools

10.) Open any browser and provide URL given as:

→ http://<docker container ip-address>/<html file>.html

So, you will see the web-page as per your html code🔥.

🎗️TASK-1 COMPLETED SUCCESSFULLY !🎗️

✳️Let’s move on Task-2:

🔅Setting up Python Interpreter and running Python Code on Docker Container.

🛡️Firstly, Do Check that python is already installed or not in docker container, if not then, install it:-

#python --version

🛡️If python version-2 has already installed but we have to use python version-3 so , install python3 by using command:-

#yum install python3
#python3 --version

🛡️Now, let’s write some code on Python interpreter:-

#python3Python 3.8.5 (default, Oct 2 2020, 14:25:46)
Type "help", "copyright", "credits" or "license" for more information.
>> print("Task Completed Successfully!!")
Task Completed Successfully!!

🎗️TASK-2 COMPLETED SUCCESSFULLY !🎗️

THANKYOU FOR READING!(*-*)🌻

--

--

Lalita Sharma
Lalita Sharma

Written by Lalita Sharma

Aeromodeller|Passionate|Technoholic|Learner|Technical writer

No responses yet