Configure Apache web server on Docker and Python Interpreter on Docker.

Abhishek kumar
3 min readMar 14, 2021

Task Description

  1. Configure Apache webserver on Docker
  2. Configure Python Interpreter and run python code on docker.

what is Docker?

Docker is a container Engine used for launching containers on BaseOS. IT launches within a second.

In this task, I am going to use RHEL8, First configure it and setup yum.

what is yum?

yum is used to the repositories for the OS, for this You have to configure it by using two software folders BaseOS and AppStream, provided by Bootable DVD. For Docker repo you have to download it from internet and put it in repo file.

  1. #cd /etc/yum.repos.d/
  2. open file with #vi <File_name_with_repo_extension>and write the url.

3. Run cmd #yum repolist

Install Docker using #yum install docker-ce — nobest

Start the Service of Docker #systemctl start docker and For enable the service #systemctl enable docker

But you won’t be able to access the internet or outer world using container. for this you have to run following commands.

  1. firewall-cmd — zone=public — add-masquerade — permanent #Masquerading allows for docker ingress and egress.

2. firewall-cmd — zone=public — add-port=80/tcp ; Allow incoming traffic on port 80.

3. firewall-cmd — zone=public — add-port=443/tcp; Allow incoming traffic on port 443.

4. firewall-cmd — reload

5. systemctl restart docker

For launching the docker, we should have a container image to launch the container. #docker pull <image_name>

Launch the docker using command #docker run -it -p 8080:80 <image_name>

use #yum install net-tools for #ifconfig command to find IP Address of container.

Install httpd software using #yum install httpd and start the service by #/usr/sbin/httpd.

#netstat -tnlp, It shows the exposed port no. of httpd server.

Go to document root of httpd server and create the webpage because it reads the file from only its document root.

#cd /var/www/html, #vi <web_page> #cat <web_page>

Now use Firefox browser for connect to the webpage on port 80.

For Installing Python Interpreter use command #yum install python3

by using command #python3, Interpreter will be enable and for comes out of it use exit()

So, This is the task. Hope you like it.

Thanks for reading.