Setup Web Server Over Docker Container in Linux

Before setting up a server we must know the real meaning or definition of a server. So, the Server is a program that provides the client with any kind of services. For example, a web server provides our websites, a database server provides us data. This means every server has work to do and for every different work we want them to do, we have to choose different servers.
For knowing more about servers and their working click here. To check more about dockers – click here.

Pre-requisite:

  1. Linux Operating system Like Ubuntu, Redhat, Kali Linux.
  2. Internet connectivity
  3. Docker installed on system

What we are going to do VISUAL:

Let’s now understand the installation and configuration.

3 steps to configure a Web Server

  • Install the Server Program
  • Configuration of Server
  • Start the server

Installing the Server Software

Start docker services.

systemctl start docker

Open the docker container, you can use centos 7 images to launch.If you don’t have centos images you can download it from the www.hub.docker.com



docker run -it --network host centos:7

We are going to use HTTPD server.It could be installed using YUM command and DNF if you are using RHEL 8.

yum install httpd

webserver installation

Configuring the Web server

Actually the server is already been configured and now its the time to update or make a website over this server.Server website can be accessed using the IP address of the host.
Setup website

cd /var/www/html/


In this directory you could save your website and it would be available over the network.

Start the server

systemctl start httpd

If this doesn’t start the server, try this

/usr/sbin/httpd

Access the content of website

To access the content of the webserver you must know the ip address, which could be known using “ifconfig” command.And then do the further steps.

 curl http://IP of host/page_name.html


Visit Webpage

My Personal Notes arrow_drop_up

Always interested in science and technology,love to make projectsPositive approach towards problems in tech or in life

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.