Configuring HTTPD server on Docker Container and setting up Python Interpreter
Last Updated :
20 Feb, 2023
In this article, we are going to discuss a step-by-step guide on how to configure the apache web server on top of a docker container, and setting up a Python interpreter. Basically, we are installing the product of apache which is HTTPD on the docker container.
What is Docker?
In simple words, if I have to define docker, is a tool that can launch an operating system (install any operating system) in seconds. If you have noticed when we install any operating system it takes around one hour to launch, but docker giving you the facility the convenience to launch any os within seconds, and httpd is just a product of apache web service which we are using for creating webpages.
Prerequisites:
- You need Virtual Box installed in your os
- And launch one Linux operating system(RHEL-8, Linux (64-bit)) in the VM to perform this practice.
- Yum, should be configured in your VM.
How to configure the HTTPD server on the Docker Container?
- First, we need to install docker in your VM so for that first use the following command to go inside the repo folder.
cd /etc/yum.repos.d/
- Create a repo by giving any name by the command vim d.repo and give this URL. You have to add this URL in the docker repo as you can see below.
toDocker repo- After this, you can install docker by using the below command:
yum install docker-ce --nobest
- To check docker installed or not run the command:
rpm -q docker-ce
- To start the service and to check the status of docker you can run the following commands:
Start docker service:
systemctl start docker
Check docker status:
systemctl status docker
Now to configure the webserver on the top of the docker container these are the steps:
- Launch a docker container with an image
- Inside which we install the webserver program(Apache server)
- Starting the server
- Inside the docker, we install python interpreter(python3)
Before launching the container in docker make sure to stop firewall and then restart docker.
Stop Firewalld- Now to launch one os /container on the top of docker we need an image you can use the image, we are using the ubuntu: 20.10 image, you can get it from https://hub.docker.com/, to download the image we have to use just one command
docker pull ubuntu:20.10
- Now you can launch the container by this image: docker run -i -t -name taskd ubuntu:20.10, the command to come out of the container is exit, you can check how many oses stopped and running also by using the command:
docker ps -a
Lunch docker container- To go inside the exited docker container we have one command docker attach taskd here taskd is the name which you give while launching the container, you can give any name as per you want. Before you go inside the container you have to first start the stopped container by below the command:
docker start taskd
Going inside the docker container - Now we can start the installation in the docker container first we use the command apt-get update, this command is used to download package information from all configured sources. So when you run the update command, it downloads the package information from the Internet. It is useful to get information on an updated version of packages or their dependencies.
apt-get update- Now we can install an apache web server on the top of docker container by the command, apt-get install apache2, in ubuntu we have this command apt-get to download and install any software.
Installing webserver(Apache) on the container- Now we have to install systemctl by using the command:
apt-get install systemctl
Installing systemctl command in container- The command: apt-get install net-tools will help you to run the ifconfig commands.
Installing net-tools
Running ifconfig to see IP- Use the below command to install vim:
apt-get install vim
Install vim to create a file- Now after this installation part gets done we have to configure the webserver we need to go to cd /var/www/html/ and there we have to create a website using vim hello.html.
Creating a website- Now start the service by command, systemctl start appache2 and check the status, make sure it's active.
Starting the web service- Now get the IP by ifconfig command and use the URL IP/hello.html in a browser.
See the website in the firefoxSetting up the Python Interpreter in the Docker Container
- First, we need to install python3 by the command:

- To see python3 is installed or not
python3 -V

Similar Reads
Launch an HTTP Server with a Single Line of Python Code Python, with its built-in capabilities, offers a simple and effective way to do this. With just a single line of code, you can launch an HTTP server to serve files from your local directory. This feature can be incredibly handy for developers, educators, and anyone needing a quick and easy way to sh
2 min read
How to Deploy Python WSGI Apps Using Gunicorn HTTP Server Behind Nginx This article describes how to deploy a Python WSGI application using Gunicorn and Nginx. Before proceeding with the tutorial, it's a good idea to first familiarize yourself with the terms WSGI, Gunicorn, and Nginx. Web Server Gateway Interface or WSGI is a specification that describes how a web serv
5 min read
How To Send Files Using Python Built-In Http Server Python's built-in HTTP server offers a straightforward way to share files over a local network or the internet without the need for complex setups. In this tutorial, we'll walk through the step-by-step process of using Python's built-in HTTP server to send files to clients. Setting Up the HTTP Serve
2 min read
Python Django - Test Driven Development of Web API using DRF & Docker We are going to create a to-do list web API using Django rest framework, docker and also going to write different tests for different functionalities in our code using test-driven development, but letâs first see what are prerequisites for this project. Prerequisites :Docker Installed on your local
11 min read
How to install Python3 and PIP on Godaddy Server? GoDaddy VPS is a shared server that provides computational services, databases, storage space, automated weekly backups, 99% uptime, and much more. Itâs a cheaper alternative to some other popular cloud-based services such as AWS, GPC, and Azure. Python is an open-source, cross-platform, high-level,
2 min read
Setting Up Docker for Python Projects: A Step-by-Step Guide Docker provides a standardized environment to develop, test and deploy applications in an isolated container ensuring that your code works seamlessly regardless of where itâs run. Setting Up Docker for Python ProjectsIn this article, we will learn about the basics of Docker and containers, how to se
5 min read