Configuring WebServer On The Top Of Docker.

Docker

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. It is founded by Solomon Hykes at DockerCon. Solomon Hykes built a wonky open-source project a decade ago that later took on the name Docker and attained a private market valuation of over $1 billion.

Web-Server

A web server is server software or hardware dedicated to running this software, that can satisfy client requests on the World Wide Web. A web server can, in general, contain one or more websites. A web server processes incoming network requests over HTTP and several other related protocols. Here we use the Apache httpd server.

We used the RedHat operating system, docker-ce, and apache web-server. docker-ce is community software and it is free to use. In docker, we have a lot of containers for use. We are configuring the web server on top of docker and deploying the website.

Steps for configuring:-

Step 1:

We have two repositories in our system, Here is the location and name of the repository.

Step 2:

Here we don’t have the package for the docker so we need to configure the yum for the docker. Here we do that. We create a file named docker-ce.repo and we give the URL for the docker.

Step 3:

Now we have three repositories.

Step 4:

We check the repository of the docker using yum repolist

Step 5:

So after we checked for the repository is available then we are ready to install the docker by using the yum command and we used the — nobest option. Command for the docker is:

yum install docker-ce — nobest

Step 6:

Now we can check whether the docker is installed or not by using the rpm command

rpm -q docker-ce

Step 7:

Now we have checked whether the docker is installed, then we are ready to start the services of the docker. Using the systemctl command.

Step 8:

After starting the services we can check the status of docker using systemctl status command. It will show running, As it shows below.

Step 9:

After every boot we have to start the docker service. So for not doing that we can use the enable the docker services. By using the :- systemctl enable docker

Step 10:

Here we have to get the image of the OS. In my case we have centos latest os. And I am downloading the 7th version of the centos. Using the docker pull command:

docker pull image_name:version

Step 11:

And we can check the available images by the following command:

docker images

Step 12:

Now we have the os image so we can run the docker container by following command:

docker run -it — name nsme_of_container os_name:version

We have successfully run the docker container!!

Step 13:

Now, Our main purpose is configuring the webserver so we have to install the Apache httpd server on the docker. Using the yum command. In centos yum is already configured so we don’t need to configure the yum in centos.

command for installing the httpd:

yum install httpd

Step 14:

After installing the webserver we go to the file named html

path for file is: cd /var/www/html

We don’t have any file in this file currently.

Step 15:

We create a HTML file to upload to the webserver. I named the file index.html. I used the vi editor for this. cat command to show what I code in the index.html file.

Step 16:

In our RedHat system we used the systemctl command to start the service. But in docker we have the centos OS so in centos they don’t have the systemctl command to start the os.

Step 17:

So to start the service we use the command:

/usr/sbin/httpd

Here they also give the IP address of the webserver ie. IP address of the docker container.

Step 18:

So we configured docker and webserver, we also deploy the website. Here is the look of the website.

If we type the IP of the container and give the file name then It will show the website that we already deployed.

command: 172.17.0.2/index.html

Conclusion

In this scenario we configured docker, WebServer and then we deployed the website on the webserver. We see the docker configuration, How to configure yum for docker. We also looked how to install webserver on docker and start the webserver in centos. And at last hoe to view the website that we hosted.

A computer Engineer Student

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