Configuring HTTPD Server On Docker Container
So when we listen about the term container technology then the very first use case that comes in our mind is running our webserver on container so that whenever loads increases on our webserver then it can launch a new container with same webserver and reduce the load on server. Through this article I gonna demonsrate configuring Apache Web Server(httpd) on docker container.
Let’s start….
Pre-requisites
- Docker installed
- Image of centos form docker hub downloaded
Launching Container
First we have to launch a container from any downloaded image in docker (I am using centos:latest here)
with command:- docker run -it -p 1234:80 — name os1 centos:latest
using command: Used ‘-it’ to get the intaracting terminal of container, ‘-p’ to expose the container httpd server(which works on port number 80) to outside world so that anyone can access with base OS ip and given port number
Installing Apache Web Server On Container
By default container don’t have apache web server installed we can check with following command: rpm -q httpd
So to install we can use yum program as: yum install httpd -y
Now if we again check with rpm command then it will show the package installed :
Creating web Page on Container
Now let’s create a web page on container first go to /var/www/html/ directory:
Here I’m just creating simple webpage for the demonstration you can create your own web page according to your all need..
Accessing Web Page
Now access the web page of container from outside world with base OS IP where docker is installed and with the same port as above with which we had exposed the container.
I’m writing 192.168.225.185:1234/home.html as address on browser where 192.168.225.185 is my base OS IP
That’s it guys hope this article helps you…
Connect me on LinkedIn for more updates