CONFIGURE WEBSERVER IN DOCKER CONTAINER

Manali Jain
4 min readNov 2, 2020

--

🔅Configuring HTTPD Server on Docker Container

DOCKER -

Docker is a tool based on the concept of Containerization. It launches + boot + login into a container in just 1 second and it is lightweight. Docker is a useful product for companies wherein one day almost 1000 O.S. is uninstalled and re-installed.

HTTPD -

This is an Apache HTTP Server which is a free and open-source cross-platform web server.

________________________

In this task, we will launch a webpage on the top of httpd. Docker makes things fast and easy for companies that launch 1000 or more servers in a day.

________________________

CONTAINER -

We can see a docker container running in our system by the “ docker ps ” command.

DOCKER PS

________________________

SELINUX -

We have to change the SELinux mode here by the command “ setenforce 0 ”.

SELINUX

________________________

DOCKER RUN-

The command which helps to Download + Launch + Boot + Login the Container is “ docker run -it — name WebServer -p 80 centos:7 ”.

Here “-i” means interactive and “-t” means terminal.

“ — name” is the name of the container.

DOCKER RUN

________________________

DOCKER RUNNING CONTAINER -

I have opened another tab and in that, I run the “docker ps ” command which is showing the running container. Also, you can see that it is running with port number 80.

RUNNING CONTAINER

________________________

INSIDE DOCKER CONTAINER INSTALL NET-TOOLS

Net-tools package allows the container to have a network connection. The command to install net-tools is “ yum install net-tools ”.

INSTALL NET-TOOLS

________________________

CHECK IP

For accessing our webpage we need to check the container IP so the command to check the container IP is “ ifconfig ”.

SEE IP

________________________

INSTALL HTTPD -

Install the httpd to make the container behave like a webserver. For installing httpd we use “yum install httpd”.

INSTALL HTTPD

________________________

CHECK HTTPD INSTALLED OR NOT-

To check whether the httpd is installed or not we use the command “ rpm -q httpd”.

HTTPD INSTALLED OR NOT

________________________

HTTPD DEFAULT FOLDER -

“ /var/www/html ” is a default directory that is accessed by httpd first. So the files in this directory are by default accessible. The command to change the directory is “ cd /var/www/html ”.Also for starting the service of httpd the command used is “ /usr/sbin/httpd ”

CHANGE DIRECTORY
WRITE CODE

________________________

URL-

By using terminal we can check our website is working or not so use “ http://IP/file.html” URL to access the webpage.

CURL

________________________

FIREFOX -

Put the IP on the search bar of the firefox to access the webpage on firefox.

FIREFOX

________________________

CHANGE THE CODE -

Change the code of the index.html file and see how we can change our code on our container.

CHANGE CODE

Search the page by the container IP and you will see the WebPage.

FIREFOX

________________________

Thank you for your precious time.🤩

Keep Sharing 🥳

--

--

Manali Jain
Manali Jain

Written by Manali Jain

You are the only one person who can Change Yourself…

No responses yet