Let’s understand few concepts related to this task
Why we use docker??
Docker is a container management service. The whole idea of Docker is for developers to easily develop applications, ship them into containers which can then be deployed anywhere within few seconds.
📌This technology was created by Solomon Hykes, March 2013.
📌You can deploy Docker containers anywhere, on any physical and virtual machines and even on the cloud.
📌Since Docker containers are pretty lightweight, they are very easily scalable.
What is the use of Apache Webserver? How it works?
📌The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows. The goal of this project is to provide a secure, efficient, and extensible server that provides HTTP services in sync with the current HTTP standards.
📌The Apache HTTP Server (“httpd”) was launched in 1995 and it has been the most popular web server on the Internet since April 1996.
📌While there’s a lot of complexity underpinning how a web server functions, the basic job of all web servers is to accept requests from clients (e.g. a visitor’s web browser) and then send the response to that request (e.g. the components of the page that a visitor wants to see).
📌Virtual hosting is one such feature that allows a single Apache Web Server to serve a number of different websites.
Now let’s move towards our practical part👇🏻
Steps are as follows :
Firstly we need to create a repo file inside folder cd /etc/yum.repos.d eg :docker.repo as you can see in below snapshot
To download docker community edition i.e a free or open-source edition we use: #yum install docker-ce — nobest here it will download stable & latest docker version from internet i.e. from repo file using site https://download.docker.com/linux/centos/7/x86_64/edge/Packages/
Now to Start Services of docker we use: #systemctl start docker
To check the status of services we use: #systemctl status docker
To permanently enable services of docker after each reboot we use: #systemctl enable docker
To configure WEB-SERVER on docker we need a O.S to download any O.S from hub.docker.com we use : # docker pull os:name
Here I am downloading centos : latest from https://hub.docker.com/_/centos?tab=tags here we can get command to run inside our o.s also we can manually download o.s from this site https://hub.docker.com/_/centos?tab=tags
💁♀️hub.docker.com is a repository site where we can find commands and images of different O.S of docker without any charges. Also, we can create our own images and upload them on this site.
To pull any image from hub.docker.com firstly we need to disable firewall security using #systemctl stop firewalld also we need to change the mode of SELINUX using #setenforce 0 then we need to restart the docker container using #systemctl restart docker.
Now we are ready to go and download centos: latest o.s.
Then to install, run, boot, and log in to o.s we use the command: #docker run -i -t os-name: version here -i mean interactive too -t terminal/bash shell.
Now to configure(install) apache webserver(httpd) inside docker container we use : #yum install httpd.
Now to start any services we use #systemctl but by default in docker it doesn’t support systemctl so how to solve this challenge??🤔
Here we have another way or trick to start web-server services so by using # /usr/sbin/httpd we can start services of web-server.
After that we need to check the status of the webserver is running or not so we need a software called net-tools.
To install s/w of net-tools we use: #yum install net-tools
Now we can check services of web-server i.e running on port number: 80 using command: #netstat -tnlp
Hence, Challenge Solved Web-Server is successfully configured on top of docker-container✌️
We can also create web-pages inside cd /var/www/html
For example : # vi gc.html
To check web-pages created or not we can use #curl http://Docker-IP/gc.html
Now we can run this web page inside our browser using docker_container-ip/gc.html as we can see in the below snapshot.
Finally, we have accomplished TASK 7.2.A i.e Configuring HTTPD Server on Docker Container.
Thank you for reading my article🤗
Keep Learning✨ Keep Sharing🤝