Configure Web-Server on Docker Container
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.
Configuring Docker :
I am configuring docker on top of RHEL 8:
To install docker Firstly, we need to Configure yum repository:
Step 1. Configure Docker repository :
STEP 1.
Go to “/etc/yum.repos.d/” by sing cd command :
$ cd /etc/yum.repos.d/
STEP 2.
Create a a repo file e.g. docker.repo by using any editor , Here I am using vi editor.
$ vi docker.repo
STEP 3.
Write
[docker]
baseurl= https://download.docker.com/linux/centos/7/x86_64/stable/
gpgcheck=0
- This is the URL you need to use at the place of BaseURL https://download.docker.com/linux/centos/7/x86_64/stable/
- setgpgcheck to 0 so no GPG authentication issue
To check Yum repository is configured by using command
$ yum repolist
See in above Image Docker repo is configured .
Step 2. Install Docker
Install Docker by using command
$ yum install docker-ce — nobest
Step3.
To start Docker by using command:
$ systemctl start docker
To check Docker started or not by command:
$ systemctl status docker
➠ To check docker is installed or not in the system, use command
rpm -q docker-ce
➠ To start docker services, use command
systemctl start docker
➠ To check docker services started or not, use command
systemctl status docker
❖ Install HTTPD Software
➠ To launch OS on the top of docker, use command
docker run -i -t --name <container_name> <image_name>
➠ To install httpd software, use command
yum install httpd
➠ These errors are due to firewall security, so stop this security first & restart docker services then install the httpd software.
systemctl stop firewalld # to stop firewall securitysystemctl restart docker # to restart docker servicesdocker start <container_name> # to start previous containerdocker attach <container_name> # to get console of container yum install httpd
➠ To check httpd software is installed or not, use command
yum list httpd
❖ Create a Web Page
➠ Create a web page inside the document root (/var/www/html), use command
cd /var/www/html # to go inside the document root/directoryvi <webpage_name> # to create a web pagecat <webpage_name> # to read the web page on cli
❖ Start Web Services
➠ To start the web services we normally use command
systemctl start httpd
But this command will not work here so to start web services you have to use command
/usr/sbin/httpd # to start web services
Now the web services are started.
➠ To open the webpage we created paste the IP address & web page on the browser.
Thus, we configured web server successfully on the top of docker.