Configuring HTTPD Server on Docker Container

Configuring HTTPD Server on Docker Container

ARTH Task 7.2 (A)

First step is to configure the yum repository for installing Docker. Go to the following directory :

/etc/yum.repos.d/

And create a new .repo file with the following content and save it.

[dockerrepo]
baseurl=https://download.docker.com/linux/centos/7/x86_64/stable/
gpgcheck=0

Next, run the following command to install Docker :

yum install docker-ce --nobest

Run the command "docker --version" to check if Docker is successfully installed.

Start the Docker service :

systemctl start docker

Download a Docker image of your choice. I'm downloading "centos" with the command :

docker pull centos

Check if the image is downloaded or not with the command :

docker image ls

It must ouput :

No alt text provided for this image

Run the Docker image with interactive option "-i" and assign a port with "-p" option and give it a name with "--name" option :

docker run -it --name docker_server -p 3000:80 centos

Now, you must be inside your new docker console. Run the command "docker ps" and it must output :

No alt text provided for this image

Now, install httpd with the following command :

yum install httpd

Check if httpd is installed or not with the command "yum list httpd" :

No alt text provided for this image

Now, we can't start httpd services with "systemctl" command because docker willn't boot. So, we start httpd services with the command :

httpd

Change the directory to :

cd /var/www/html

Create a .html file inside the above directory and add any html code to the file. My html code :

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ARTH Task-7.2 (A)</title>
</head>
<body>
    <p style="font-size: 50px;text-align: center;color: cadetblue;">This Is The Web Server On Top Of <span style="color:darkcyan;font-size: 70px;">Docker</span> </p>
    <p style="text-align: center">
        <img src="https://raw.githubusercontent.com/asks1012/flutter-images/master/docker_facebook_share.png" alt="wallp
aper1" width="450" height="350" style="border: 4px solid black;">
        <img src="https://raw.githubusercontent.com/asks1012/flutter-images/master/apache-httpd-logo.png" alt="wallpaper1" width="450" height="350" style="border: 4px solid black;">
    </p>
    <p style="text-align: center;font-size: 50px;color: cadetblue;">Thanks For Viewing</p>
</body>

</html>

Finally, Head on to the url : (I've used my Public IP of AWS EC2 Instance)

http://PublicIP:PortAssigned/html_file_name

My final web page looks like this :

No alt text provided for this image
Thanks for Reading

Great work Akurathi Sri Krishna Sagar , this is totally your hardwork. ✨

Like
Reply

To view or add a comment, sign in

More articles by Sri Krishna Sagar Akurathi

Others also viewed

Explore content categories