This repository contains methods to Dockerize Python Projects.
-
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-
- Check Docker Hub: [Docker Hub URL]
-
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-
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)
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.
FYI: Refer [Source Code] to compute Request/Response like below:
- docker rm -vf $(docker ps -a -q)
-
Check Docker Hub: [Docker Hub URL]
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:
- On Azure, Create Resource -> Web -> Web App for Containers
-
-
This example illustrates how Jupyter Notebooks can be shared on MyBinder which Dockerizes the Notebook under the hood. [Source Code]
- Open https://mybinder.org/
- Fill the required fields:
Notice:In case you want to share your binder link: https://mybinder.org/v2/gh/rahulvaish/Docker-Python/JupyterBinder?filepath=IRIS.ipynb - Click Launch
- FYI: