Configuring HTTPD Server on Docker Container
In the following article we are going to configure the HTTPD server on the Docker container. In this practical we're using RHEL8 as Base operating system and Apache HTTPD as webserver.
What is Docker ?
Docker is an open source containerization platform used to configure the environments on the top of base OS. It is an application build & deployment tool. The time taken to install, boot and set up the OS from Docker is almost 1 second. It also needs very less RAM around 30Mbs.
What is Web-Server ?
Web-Server is a computer that runs a websites. It’s main objective is to provide web services to its clients. A web server processes incoming network requests over HTTP and several other related protocols.
Web-Server on the Top of Docker
Let's start with the practical..
Step 1 : Install Docker software on Base OS (RHEL8)
To install the Docker software on RHEL8 first we have to create the repo for the software.
cd /etc/yum.repos.d/ gedit docker.repo
yum repolist
Step 2 : Install the Docker software
yum install docker-ce --nobest -y
To check if it's installed, we check version of Docker
Step 3 : Start the Docker
systemctl start docker systemctl status docker
Step 4 : Pull any Docker Image
Initially there will be no docker image available so we pull the image from Docker repository.
docker images
docker pull centos:latest
Step 5 : Launch the Docker container with this image
docker run -it --name mywebos centos
To check all running containers
This centos image that we have pulled don’t contain ifconfig command. So we can install a software which provides ifconfig command, i.e., net-tools.
yum install net-tools -y
Now ifconfig command will work.
Step 6 : Install apache HTTPD software
yum install httpd -y
Step 7 : Put the web page inside " /var/www/html " directory
HTTPD software by default reads the file from " /var/www/html " directory. So we have to put all the HTML files here.
Step 8 : Start the HTTP service
At last, we have to start the HTTPD service. 'Systemctl' command is not present in docker containers by default. So since systemctl internally loads " /usr/sbin/httpd/ " file to start the service, we can use this file.
Now we can access the web page from the browser.
URL - https://172.17.0.2/mywebpage.html
We have successfully launched the Webpage on Docker container.
***** THANK YOU FOR READING!! *****