Skip to content

rahulvaish/Docker-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 

Repository files navigation

This repository contains methods to Dockerize Python Projects.

Table of Contents


  • This example illustrates how to Dockerize a simple Python Project. [Source Code]
    • Download the HelloWorldPythonDocker project.
    • Navigate inside the HelloWorldPythonDocker project folder from Docker QuickStart Terminal.
    • Execute the below commands- image image
    • Check Docker Hub: [Docker Hub URL] image

  • This example illustrates how to Dockerize a Flask WebService Project. [Source Code]
    • Download the FlaskWebServiceDocker project.

    • Navigate inside the FlaskWebServiceDocker project folder from Docker QuickStart Terminal.

    • Execute the below commands-
      image image
      Before executing the below commands, I preffered to clean the docker history. Followed the below commands:

      • docker rm -vf $(docker ps -a -q)
      • docker rmi -f $(docker images -a -q)

      image Here we have used -p which specifies the port it is going to run on. In our Calculator.py file we used app.run(debug=True, host=’0.0.0.0') so we needed to specify which port when using flask run , which above you can see I used 5000.
      image


      FYI: Refer [Source Code] to compute Request/Response like below: image


    • Check Docker Hub: [Docker Hub URL] image

    NOTE: The above service is not meant to be executed on Cloud Environment. To design the project we need various other components like gunicorn which gets dockerize along with the service enabling it to get executed on any Cloud Environment. Follow the below steps:

    • Code the Web Service Project [Source Code]
    • Dockerize the Project:
      image image image image
    • On Azure, Create Resource -> Web -> Web App for Containers
      image image