Configuring HTTPD Server on Docker Container

Arya Dhorajiya
3 min readNov 10, 2020

So, We have been given these small tasks to complete under the Docker container topic, and it’s very easy to use without any complications.

Step 1 : Start Docker Services and run the CentOS image

We can run a previously created image using the command docker run -dit — name webos centos:latest

This will execute and create a container. Now, we need to start and attach the container.

Step 2: Disabling the SELinux Security.

It’s the internal security for administrative permissions to execute containers or automation softwares like Jenkins.

Step 3 : Installing httpd package inside the container

Use the command yum install httpd to install the httpd package.

Step 4 : Creating a html file inside the /var/www/html folder

Creating an html file inside this folder will automatically execute the file and will open the html page while browsing.

Step 5: Installing ifconfig command files

We searched for ifconfig files using yum’s sub-commands

We saw that, it is installed with net-tools, so we installed it using yum install httpd

Step 6 : Starting the httpd service

Execute /usr/bin/httpd file to start httpd service..

Step 7 : Using ifconfig to find the IP and connecting to it using the browser

After we use the ifconfig command, we get the IP Address 172.17.0.2, so we browse to it using the browser and we can see, the html file is executed. This states that we successfully executed a html file inside a docker container.

(B) — Setting up Python Interpreter and running Python Code on Docker Container

Setting up a Python Interpreter inside the Docker Container is very easy, we just need to install Python3 files and make a simple print function in a .py file

Step 1 : Installing python3 files

Use the command yum install python3 to install Python Packages..

Step 2 : Creating and executing a .py file

We created a file hello.py, and executed it using python3 hello.py, which gave us the output of successful execution….

Thank you for Reading.. :D

--

--