Javascript Integration with Docker

Python CGI with Docker

(Task 7)

?In this project, I have integrated python with Docker !!


Python is one of the most popular languages nowadays and Docker is used for containerization.

What is python CGI?

A CGI script is invoked by an HTTP server, usually to process user input submitted through an HTML?<FORM>?or?<ISINDEX>?element.

Most often, CGI scripts live in the server’s?special?cgi-bin?directory. The HTTP server places all sorts of information about the request (such as the client’s hostname, the requested URL, the query string, and lots of other goodies) in the script’s shell environment, executes the script, and sends the script’s output back to the client.

For now info visit?:

https://docs.python.org/3/library/cgi.html

Whats is docker?

Docker?is a set of?platform as a service?(PaaS) products that uses?OS-level virtualization?to deliver software in packages called containers. Containers are isolated from one another and bundle their own software,?libraries,?and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single?operating system kernel?and therefore use fewer resources than?virtual machines.

Now starting with my project,

Step 1:For this firstly I installed docker engine on my red hat 8 using command

# yum install docker -ce --nobest

Step 2: Then I started docker services using

#systemctl start docker

Step 3: Then I made one directory for my project using #mkdir doc_project and in this directory, I made my one file try.py which will have my code related to python CGI which is made using html, CSS, and python 3.

Step 4: In the same directory I will make one more file named Dockerfile which is used to make my own docker image and the configuration inside this file will be like shown in the figure below?:

No alt text provided for this image

In this we have installed one apache server?and python?3?. Then copied my try.py file into the root directory of apache server for cgi related fields root directory is /var/www/cgi-bin/ and for other purposes root directory of apache will be /var/www/html/.

So after I copied this file I have given executable permissions to this file using chmod command

And then as I normal os, we can start httpd services by using #systemctl start httpd but this will not work inside Docker so for starting httpd services i have used the last command.

Step 5:Then I will build my image using this Dockerfile and the command used for this will be

# docker build -t any_name

For e.g., :

No alt text provided for this image

Step 6: After making this image i will run this using command?:

#docker run -i -d -t -p any_free_port:port_of_httpd --name any_name image_name

For e.g.,:

No alt text provided for this image

Step 7: Now our container is ready to work on. Now I will put my IP address of base os with the port I have given on any browser which is connected to same network

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image


Mashfooq Ahmed

Senior Associate, Infrastructure Specialist

3 年

Congratulations

回复

要查看或添加评论,请登录

KARTIK LOKARE的更多文章

  • How to read data stored in RAM?(Memory Forensic)

    How to read data stored in RAM?(Memory Forensic)

    What is RAM and What data RAM contains? Random-access memory (RAM) is a computer’s short-term memory. None of your…

  • Explore date command and with options and try to use every option.

    Explore date command and with options and try to use every option.

    The date command displays or sets the system date. It is most commonly used to print the date and time in different…

  • Object Recognition using CNN model

    Object Recognition using CNN model

    Step 1: Create an ML model detecting vehicle number plate Step 2: Display the screen showing the WebApp taking the…

  • Kubernetes Integration with Python-CGI

    Kubernetes Integration with Python-CGI

    Kubernetes Kubernetes (also known as k8s or “kube”) is an open source container orchestration platform that automates…

    3 条评论
  • Industry Usecase of JavaScript

    Industry Usecase of JavaScript

    August 12, 2021 Introduction JavaScript is a programming language used primarily by Web browsers to create a dynamic…

    2 条评论
  • K-Means Clustering - Use Cases

    K-Means Clustering - Use Cases

    What is Clustering? Clustering is one of the most common exploratory data analysis technique used to get an intuition…

  • Understanding Confusion Matrix

    Understanding Confusion Matrix

    Hello Everyone… Today I am here with a interesting article. Which is based on Confusion Matrix.

    3 条评论

社区洞察

其他会员也浏览了