In this story, we will see how to dockerize the API and deploy it. (pat-1)
let’s undetstand some most useful and basic commands of Docker
step 1 — Create Dockerfile
Create a new file and rename it
before moving, we have to make some changes in flask app
Now, Inside Dockerfile
COPY . /usr/app
RUN pip install -r requirements.txt
CMD python flask_app.py
Creat your requirements.txt file by following command
pip freeze > requirements.txt
Step 2 — Build docker image
docker build -t "<app_name>" .
Eg: docker build -t noteAuth_api .
Step 3 — Run the Docker container after build
docker run -p 8000:8000 noteAuth_api
manage your all running container
docker ps # You can see you container id , status and name etc
If you want to access the ip address for a specific running container
docker inspect "<Container_id>"
Kill and remove container
docker rm "<container_id>" -f
If you will use flasgger_app.py from my github repo which is created with flasgger (
pip install flasgger ) for User interface. Output will be like running on Doker
Congratulations 🥳 ! You made it.This is it with Dockers.
There is a lot to learn on dockers but at beginner level it is sufficient.
In the upcoming story, we will see How to deploy Machine Learning pipeline on Google kubernates Engines.