Launching A Webserver & Python Interpreter On Docker Container

TASK-7.2 of ARTH — The School Of Technologies

TASK DESCRIPTION:

🔷 Configuring HTTPD Server on Docker Container

🔷 Setting up Python Interpreter and running Python Code on Docker Container

What is Docker ?

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.

The Docker platform

Docker provides the ability to package and run an application in a loosely isolated environment called a Container. The isolation and security allow you to run many containers simultaneously on a given host. Containers are lightweight because they don’t need the extra load of a hypervisor, but run directly within the host machine’s kernel. This means you can run more containers on a given hardware combination than if you were using virtual machines. You can even run Docker containers within host machines that are actually virtual machines!

Docker provides tooling and a platform to manage the lifecycle of your containers:

  • Develop your application and its supporting components using containers.

TASK COMPLETION:

To Use Docker Tool we have to Install the Docker Software .To Install Docker Software in RHEL8 Use the command as :

dnf install docker-ce --nobest

After Installing Docker Now we are Ready to Perform the TASK .

1) We have to Configure the HTTPD Server Inside Docker Container . For that we have to first launch one Docker Container . In my case I have used CentOS Image for Docker Container .

To launch any Docker Container Docker has Command as :

docker run -{options} --name {name_of_container} {image_name}

To Download the Docker Image used for the Container Docker has Command as :

docker  pull  {image_name}

We are now launching the Docker Container of CentOS Image by Running the Command as:

2) Now after Creating Docker Container we have to Install HTTPD Package for Configuring Webserver .

yum install httpd -y

3) To check the status of any service in Linux we normally use systemctl command .But Inside Docker Container by default some commands are not configured .For these to check the status of HTTPD Service just type httpd which shows the status of that service .

4) Finally the Webserver is successfully configured inside Container . To test the Webserver let’s write simple html code inside Document Root /var/www/html of Apache Webserver .

Integrating Docker with AWS Cloud

Putting the Web Code Image inside AWS S3 Bucket →

Creating Cloud Front Distribution for the Image Inside S3 Bucket →

5) Finally just keep that URL Provided by Cloud Front for the Image Content inside html code . Now our static content in the webpage is high in terms of Availability and connectivity .

6) Now let’s check the Apache webserver is configured well or not . To access the Apache Webserver content inside Docker Container we have to use <public_ip of host>:9091.

We can see the Home Page of Apache webserver means We have successfully configured the Webserver .

Accessing the Web Page — ->

7) Now we have to Launch Python Interpreter Inside the Docker Container . For that we require Python software to be Installed in our system .

💠 Installing Python3 Inside Docker Container — ->

yum install python3

8) At last we have to Run simple python code on the top of Docker . For that I have used Python3 REPL Live Interpreter to run System Commands of Docker Container by Importing OS module in Python3 .

And this is how configuring HTTPD Server on Docker Container and Setting up Python in Docker is achieved.

If you find it useful please clap it.

Connect with me on LinkedIn | GitHub

Lifelong learning technologies

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