Configuring HTTPD Server on Docker Container

Docker Container

A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.

A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

Container images become containers at runtime and in the case of Docker containers — images become containers when they run on Docker Engine. Containers isolate software from its environment and ensure that it works uniformly despite differences for instance between development and staging.

Now to configure the HTTPD Server on Docker Container the first step is to download the docker

  1. The command used to install docker is
yum install docker-ce --nobest -y

2. After this we have to start the docker service the command used is

systemctl start docker

3. After this pull the centos:7 image. The command used is

docker pull centos:7

[root@localhost ~]# docker pull centos:7
7: Pulling from library/centos
2d473b07cdd5: Pull complete
Digest:sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d8904942430789b60e
Status: Download newer image for centos:7
docker.io/library/centos:7

4. Launch the docker container using the command.

docker run -it — name containername imagesname:imageversion

[root@localhost ~]# docker run -it --name WebOS centos:7

5. Install the webserver using the command.

yum install httpd -y

[root@localhost ~]# yum install httpd -y

6. Go inside the /var/www/html directory and make a webpage using the command

cd /var/www/html

[root@localhost ~]# cd /var/www/html
[root@localhost ~]# vi webpage.html

7. Now inside the webpage write the html code and save it using :wq

8. Now start the webserver but using the command

systemctl start httpd may give an error so prefer using the command

/usr/sbin/httpd

to run the webserver.

[root@localhost ~]# /usr/sbin/httpd

9. Now you can take the IP address and then access it on the google of your local system to see the webpage you have created

10. Or you can also check using the command

curl http://ipaddress/webpage.html

[root@localhost ~]# curl http://172.31.36.224/webpage.html
Hello this is running on docker
[root@localhost ~]#

Hence the httpd server is configure on the Docker.

Hope it was helpful to you.

Thank You!!

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to start Python Flask REST API

Power BI Local Timezone Issues… and Beyond

VOIP Providers in Rhondda Cynon Taf #Business #VOIP #Providers #Rhondda #Cynon #Taf https://t.co/tWC

CS371p Fall 2020: Elias Lampietti

LSP Reward Report — January 2022

Sneak view into Docker for Web devs | Part-1

How to generate short-lived GCP Service Account Keys or OAuth2 tokens with Vault

Why I wouldn’t choose S3 bucket notifications again

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
Aashi Gupta

Aashi Gupta

More from Medium

Installing python dependencies using wheels

Using Python to scrape and perform ETL (Extraction, Transformation, Loading) on Best Selling Mouse…

Python Socket Timeouts

How Do Various Actor-Critic Based Deep Reinforcement Learning Algorithms Perform on Stock Trading?