Configuring Apache Server and Python on Docker Container

Firstly to use Docker we should know what Docker exactly is and Some more things about it like how to install it and most importantly how to use it.

What Docker exactly is..?

Docker is a set of platform as a service (PaaS) 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 well-defined channels.

And most importantly it has the capability to launch the operating system in just 1 second after the command is been executed.

Now as we have to configure the Apache server on Docker so for this we should also know something about HTTPD server.

Apache HTTP Server

The Apache HTTP Server, colloquially called Apache, is a free and open-source cross-platform web server software, released under the terms of Apache License 2.0.

Apache HTTPD is an HTTP server daemon produced by the Apache Foundation. It is a piece of software that listens for network requests (which are expressed using the Hypertext Transfer Protocol) and responds to them. It is open source and many entities use it to host their websites.

Container

Containers are basically the operating systems launched using Docker tool.

Prerequisite

•We should have Docker pre-installed and setup in our local VM.

Lets move ahead and start…

➥Check status of Docker

Firstly we have to check whether Docker services are running or not , and if they ain’t running then we have to start them using the below command.

#systemctl start docker

➥Pulling Docker Image

Here I have used Ubuntu image in docker to launch a container, so we have to use this command to pull this Image.

#docker pull ubuntu

➥Launching Container

We have to download a Container using that Ubuntu Image and at the same time we also have to expose it for further use using the below command.

➥Installing Apache HTTP server

Before installing the apache server firstly we need to update packages in reposirories by using “apt-get update” command.

Now we gonna install HTTP and for it we generally use this command

#apt-get install httpd

but sometime repositories don’t contain desired packages, they provide some other packages which includes our virtual package. So I am gonna use this command to install Apache server.

#apt-get install apache2

Now you should know one thing that the directory in which we keep files of our HTTP server is /var/www/html and after installing apache server if you are able to go inside this directory then it means everything is all good.

Also we have installed Vim command in this above image , Vim is basically a text Editor in linux.

➥Configuring the server

After installing the server we have to Configure it that is we have to upload content( or you can say files) in it.

So I have created one file file.txt having this content in it

Server is configured now , we just have to start the services.

➥Starting Apache server services

Apache services are running fine, Now if we want to check whether our server is responding to clients or not we have 2 ways for it:

  1. Server has a default Index.html page inside it , go and check it on browser and if you are getting this kind of page means server is working good.

2. you can also check the page you created(file.txt)

You can see server is working fine as you can see your site.

➥Installing Python Interpretor on Docker container

To install Python on container we can use this command

#apt-get install python

And you can see its working fine and you can code here easily .

Thank you for reading…!!

--

--

Upcoming Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store