Configure Web Server And Python Interpreter on Docker Container

Kumawatpayal
4 min readNov 18, 2020

Hello Everyone….!!!

This article is about configure HTTPD webserver and python Interpreter on Docker Container.

Task Description…

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

Lets get Started….

Step 1. First we need to install Docker on top of our system, Here I am Using rhel-8 Linux OS.

Before Installing docker we need to configure the repository of the Docker, for repo configuration we need to follow some step-

  1. First Go Inside Yum Repo using “cd /etc/yum.repos.d/” command in your linux os.
  2. Create a repository file with .repo extension and put the URL location from where you will download the docker
docker repo configuration

you can also make the repository directly via “wget download.docker.com/linux/centos.docker-ce.repo” command.

Step 2. Then you can install docker using “yum install docker-ce - -nobest” command.

docker tool comes with two edition first one is Community Edition(CE) and second one is Enterprise Edition(EE). Here Am using Community Edition. Community Edition is a open Source where as In Enterprise Edition we need to purchase a license .

docker-ce →for Docker Community Edition.

--nobest →install with current latest version.

docker installation

After successfully installed docker in our system, we have to start its services.

Step 3. “systemctl start docker” for starting docker services. Instead of start we can also used enable for starting the docker services permanently.

starting docker services

After started services we can check whether services started or not using “systemctl status docker” command.

Step 4. Then we have to download OS Images from docker hub using “docker pull Os image Name:Version” command.

docker hub is a centralized repository which contain the os images. here we can also create our own os image.

pull centos image with version

step 5. “docker run -it --name webos centos:7” for launching new docker container.

In this command,

run → launce new os.

it i stand for interaction and t stand for terminal.

webos → Its a name of docker container(os).

new webos container

here, In above image the user are change from local host to some random number. this number is a id of webos container its mean that am inside the docker container.

step 6. Configuring Httpd Server.

for configuring any webserver we need to follow three step process - -

  1. Install httpd software.
  2. Start the services.
  3. put the html webpages inside /var/www/html folder.

To install httpd webserver on top of docker container use “yum install httpd” commad.

install httpd webserver

Docker don’t support the “systemctl start httpd” command , Here to start the Web Server service we need to use Internal Command “/usr/sbin/httpd” which systemctl uses.

start services

Then put all your html webpages inside /var/www/html folder.

create index.html using vi editor

After then check that webpages is available or not on browser use “172.17.0.2/index.html”. But before these make sure your firewalld is stopped. you can stop firewalld using “systemctl stop firewalld” command.

index.html page on browser

In the above image 172.17.0.2 is a ip of docker container.

Setting Up Python Interpreter and Running Pyhton Code On Docker Container

To setup python Interpreter we need to install pyhton3 in our docker container.

use “yum install python3” for installing python with version 3.

installing python3

above image am using rpm -q python3 command for checking python3 is install or not in our system.

After successfully installed then we can run any python code here.

run python code

Thanks For Reading!!!!!

--

--