Web Server and Python Interpreter Configuration on Docker Container

Aman Goyal
4 min readMar 20, 2021

Docker :- Docker is a very famous Container engine . It is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels.

Task Overview :-

đź”…Configuring HTTPD Server on Docker Container
đź”…Setting up Python Interpreter and running
Python Code on Docker Container

Lets start with Installation process of docker

After setting up Repo For Docker start installing it as mentioned below

Check whether docker is installed or not by command:-
rpm -q docker-ce

Now start docker services and then Launch 1 container for Launching Webserver . Follow these commands

systemctl start docker
docker ps
docker run -it — name OS_For_WebServer centos:latest

You can Put any name of OS . Here I’m using centos Image for container

Now we are in our docker container which you can See on your command line by user identity . Now we need to install http server over it . so for that

After successfully installation of http server , we need to write some file to show on hosted server . for that we need to go to /var/www/html folder as it is by default directory of httpd server where it collects all its files to be host . So Follow these steps :-

Add some code here in index.html . The code I wrote is as follow

to save it press esc then :wq and enter

Now just Start services and Our website launched . But as it is docker container and launched as centos , it don’t support systemctl command . so we need to go to its configuration file and start from there or run this command:-

/use/sbin/httpd

Service Started

now get the ip of your container and put it in browser to check the hosted website. to get ip use command : ip addr

Here is the Result of what we do . That’s how we launch a webserver over docker container .

Now we want to Launch python interpreter on docker container . I’m using same Container for this task .

First install python latest version in it .For that use command :- yum install python3

Now create 1 directory for python code , go there and start writing code

code that I wrote for this demo is as follow

To run this :-

That’s all With setting up python interpreter and running code on docker container .

That’s all with this article. I hope you found the post Informative, if something was missing or you think some more things could have been added, feel free to provide suggestions in the comments section or on LinkedIn.

You can check out my LinkedIn profile.

Thanks for giving your precious time to this article✌ Hope you like it .

--

--