7.2: Docker Task

7.2: Docker Task

In this article I will explain how to:

Create a Dockerfile file describing a simple Python container.

Task Description

🔅Configuring HTTPD Server on Docker Container

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

Prerequisites

  • Docker install in the base system.
  • A runnable Python web page.

Step1: create Dockerfile

  • In this Dockerfile we need to first select which docker image we need. here I am going create to create image using centos docker image.
  • then I am installing 2 software 1. httpd server to configure the apache web server 2. python3.
No alt text provided for this image
  • I am copying index.py file in /var/www/cgi-bin/ folder . content of index.py is below. this is simple python code to run date and cal command .
No alt text provided for this image
  • then we can start service of web server. and expose this image to port no 80.

step2: create a image using this Dockerfile

command to create docker image using dockerfile

  • docker build -t <any name > <path of Dockerfile>
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

we can see created docker image using command

  • docker images
No alt text provided for this image

Step3: Luanch an Container using created image

command to launch conatiner using docker image

  • docker run -dit -p 81:80 --name <container name> <image name>
  • in the above command "-p" is used to expose the container so that we can access the web page outside the bash os too.

command to see the status of container

  • docker ps and docker ps -a
No alt text provided for this image

step4: access the web page

we can access the web page which we have configure using apache web server and python3 code in /var/www/cgi-bin/ folder.

  • http://192.168.43.182:81/cgi-bin/index.py
No alt text provided for this image

this is output of webpage, which is written in python language and running in docker container .

Thank you for reading this article








Very useful

Like
Reply

nyc sulekha

Like
Reply
Sudhanshu Tripathi

Senior Data Engineer at Cigna | DevOps Advocate | IaC Expert | ETL | Data Lake | Terraform & AWS Certified Solutions Architect

4y

nice work !!

Like
Reply
Satyam Kumar

DevOps Engineer at Celebal Technologies

4y

Thanks for sharing

Suhaib Ansari

Software Developer @Hotfoot ...😇

4y

Great work👌 sulekha

Like
Reply

To view or add a comment, sign in

More articles by Km Sulekha

  • Docker GUI Task26

    This article describe how we can launch GUI software on Docker. Task Description *GUI container* on the *Docker* Launch…

  • HotStar Case Study Task2

    This article will describe the journey of Hotstar’s infrastructure from EC2 to Kubernetes. The journey about why, what,…

    1 Comment
  • Case Study of AWS SQS

    In this article I am going to share what is Amazon SQS and industries use case of Amazon SQS. Amazon SQS Amazon Simple…

  • ARTH Task18

    In this article we are going to explain how to we can configure WordPress on ec2 instances and connect this with Amazon…

  • Arth2020 Task17

    In this article we are going to create chat program using python socket programming and Threading. Task Description…

    2 Comments
  • Create a setup so that you can ping google but not able to ping Facebook from same system Task13

    This article is to explain how we can create an interesting networking setup in which only we can reach to google but…

  • How big MNC's like Google , Amazon etc stores, manages and manipulate Thousands of Terabytpes of data with High Speed and High Efficiency Task-1

    In a world where competition is intense, users will simply dump you, if your app slows down or freezes. So your…

  • Industries use case of AKS ✨

    Kubernetes is by far the most popular container orchestration tool, yet the complexities of managing the tool have led…

  • Ansible-Tower

    In this 3 hours of session we learn practical demo how industries are using Ansible-Tower and how it gives lots of…

  • Arth2020 task12

    This article is to explain how to configure a highly automated setup for Reverse proxy i.e Haproxy and update it's…

    5 Comments

Insights from the community

Others also viewed

Explore topics