Configuring Web Server And Python Interpreter Using Container Technology : Docker

Aman Dev Verma
4 min readMay 30, 2021


What is containerization?

Containerization is defined as a form of operating system virtualization, through which applications are run in isolated user spaces called containers, all using the same shared operating system (OS). A container is essentially a fully packaged and portable computing environment:

  • Everything an application needs to run — its binaries, libraries, configuration files and dependencies — is encapsulated and isolated in its container.
  • The container itself is abstracted away from the host OS, with only limited access to underlying resources — much like a lightweight virtual machine (VM).
  • As a result, the containerized application can be run on various types of infrastructure — on bare metal, within VMs, and in the cloud — without needing to refactor it for each environment.


Docker is an open source platform for developers and system administrators to build, ship, and run distributed applications based on Linux containers. Docker enables you to separate your applications from your infrastructure, so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.

By including libraries and other dependencies, applications can be transferred from one machine to be easily run on another.

Because Docker makes use of the Linux kernel housed on the machine it’s running on, regardless of any differences or customized settings, so long as any non-native elements are included within the package, your applications will run on any Linux machine. This means developers are more able to focus on coding without having to build around a specific system.

Features of Docker

➡️ An isolated, rapid framework.

➡️ An open source solution

➡️ Cross cloud infrastructure

➡️ Moderate CPU/memory overhead

➡️ Fast reboot


🔹 Configure Docker

🔹 Start and enable Docker services

🔹 Run Docker Container

🔹 Install HTTPD Software

🔹 Add content of web server to /var/www/html/

🔹 Accessing docker IP

🔹 Install Python

🔹 Run a python code by creating file

Configure docker repository :

Change directory to: /etc/yum.repos.d/

Create a docker repo as shown below:

So as we can see the docker repo has been updated:

yum repolist

Install Docker:

yum install docker-ce — — nobest

Start and enable docker services:

systemctl start docker.service

systemctl enable docker.service

Run docker container:

docker run -it — — name <container_name> <os_image:version>

Install httpd package in the launched container

yum install httpd -y

If the following error occurs:

Then run the following the commands in the docker host system after exiting from docker container (exit command):

Change directory to: /var/www/html/

Add a web pages to this folder.

Start httpd services in the docker container

Use curl command to access docker IP

Install python in docker container:

yum install python3 -y

Create a file using .py extension (example

Run the python file.

python3 <file_name>

I hope this article will help you! Thanks for reading.