Configuring HTTPD Server and running Python code on Docker Container…

Sangeeth Sahana D
3 min readNov 18, 2020

--

What is Docker?

A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings, that makes it efficient in terms of space as well as time!

PART 1: Configuring HTTPD server on Docker Container…

STEP 1:

How to install Docker on Linux OS (RHEL 8)?

→First go inside the yum repo directory using the cmd,

cd /etc/yum.repos.d/

→Then create a filename called docker.repo and write the following lines,

[docker]

baseurl=https://download.docker.com/linux/centos/7/x86_64/stable

gpgcheck=0

→ Then run the yum repolist command to check that your docker repo is successfully created and configured.

STEP 2:

yum install docker-ce --nobest -y

The best possible version (by using nobest) of docker has been successfully installed!!! We can run docker --version cmd in order to confirm the successful installation.

STEP 3:

Start the Docker Service in your base OS

systemctl start docker

Check the status (active/inactive) by using systemctl status docker

Launching Docker OS

In order to use Docker OS, we need to pull a Docker image,

docker pull centos

docker images

docker run -it — name webserver centos:latest

Now we are inside our Docker OS (Centos)!

Configuring Apache server on top of Container

STEP 1:

yum install httpd

STEP 2:

Go inside /var/www/html using cd cmd, and create a file and put some content..

→ Now we need to start httpd service and for that we need to use the following command since systemctl start httpd doesn’t work in container OS

/usr/sbin/httpd

Service has been successfully started!!

Configuring httpd on docker is Successfull!!!

PART 2: Setting up python interpreter and running a python code!

STEP 1:

yum install pyhton3

Python Successfully installed!!!

STEP 2:

You can either run the Python interpretor by using python3 cmd or create a small .py file run python3 filename.py.. In either way your python code is successfully running on your docker container!!!

Conclusion:

We’ve successfully installed docker, configured HTTPD service on top of docker and finally set up the python interpreter and got the output by running a simple python code!!!!

--

--