Deploying Web Server and setting up Python Environment on the Docker Container.

🔘Goal for this blog:
🔅Configuring HTTPD Server on Docker Container
🔅Setting up Python Interpreter and running Python Code on Docker Container
So Let’s Start
🔅Configuring HTTPD Server on Docker Container:
I am going to launch an ec2 instance on AWS cloud on the top of which we are going to install the docker


I have successfully login to our instance using Putty.
Now i am going configure yum repository for installing the docker-ce, to do this first i have to go /etc/yum.repos.d directory, then i have to create a file with .repo extension .
Here in my case i have created docker.repo file in which i have written the following things:

Now we have successfully configured the repo for docker, to install the docker we have to write the command :
#yum install docker-ce — nobest


Now docker is successfully installed on the top of ec2 instance.
to check this we have #rpm -q docker-ce command

Now we have to start the docker service using systemctl command:
#systemctl start docker

Next step is to download the docker image of Centos OS:
Now to pull the image we have the command:
#docker pull <image name>

Next Step is to Launch the container:
for this we have the command;
# docker run -it — name webserver centos:latest

ifconfig command doesn’t pre-installed here. So we can ask yum that which software provides us ifconfig command :

So we need to install the net-tools software to use ifconfig command.

we can run ifconfig command to know our IP address.

🔴To Configure Apache httpd webserver on docker container we have to follow certain steps :
1️⃣Install httpd software
2️⃣Put the webpages in /var/www/html
3️⃣Start the Service
Step-1: Install httpd software
To install httpd software, run #yum install httpd command inside the docker container.

Step-2:Put the webpages in /var/www/html
we have created an html file web.html


Step-6: Start the HTTPD Service
Normally to start the service we always use systemctl start httpd command. But in docker container by-default systemctl command doesn’t work. Here to start the service we use /usr/sbin/httpd
To check that we have successfully started the service, we can run the command #netstat -tnlp if it shows port 80 then the service is started.

🔅Setting up Python Interpreter and running Python Code on Docker Container:
To setup Python Interpreter we have to install python3 in the container, for this we have the command :
#yum install python3

Now we can run the any python code on the system by run command
#python3

Thanks
For any Query ping me on the LinkedIn:
Connect with my mentor: Mr. Vimal Daga