Docker Task: Setting up Web Server & Python Interpreter

Arjun Singh
4 min readNov 6, 2020

--

A documentation blog that would help you get started with Docker

Credits: Google Images

Before coming to the main tasks, let’s go through a brief introduction of docker.

According to the official Wikipedia explanation for docker, it is explained as follows:

Docker is a set of the platform as 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 a well-defined channel.

In simple words, Docker is the DevOps tool that isolates the environment for the software products to work without interfering with one another. Also, setting up the Docker container is faster than setting up a whole system to work upon.

The tasks which I am going to perform and explain are as follows:

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

TASK 1: Configuring HTTPD server on Docker

HTTPD is the software created by the Apache community for Web Services. I am going to configure the httpd web server.

Step 1: Download the CentOS docker image

Step 2: Launch (Run) the docker container

Step 3: Install net-tools (for ifconfig to know IP Address) using yum

We already got pre-configured yum in the CentOS image, but ifconfig was not pre-created in the CentOS image

Now, use ifconfig to get IP address

IP address: 172.17.0.2

Step 4: Install apache httpd using yum

Step 5: Go to the Document Root (/var/www/html) and make a web page to to served by the web server

Step 6: Start the httpd service

Now, here we face a problem in docker as it does not support the systemctl command

So, what we do is, we go to the docker host terminal and figure out which internal command is run on behalf of systemctl start httpd

So, finally we start the service using the /usr/sbin/httpd command and see that it is working fine by checking the port 80 as listening via netstat -tnlp command.

Step 7: Go to the web browser and browse the hosted web page

TASK 2: Setting up Python Interpreter and running Python Code on Docker Container

Step 1: Install python3

Step 2: Write a simple python file

Step 3: Run the python code

This was all from the Docker tasks.

Thank You.

--

--

Arjun Singh
Arjun Singh

Written by Arjun Singh

Student, Learner, Explorer, Coder

No responses yet