Category: Data, Ubuntu, Docker, github

In this article, we will not discuss developing Machine Learning model but rather containerizing our ready to deploy ML API (Flask) with the help of Docker so that there is no hassle that our model is not working in the production environment or while deploying it on cloud or simply sharing the working model to friends and colleagues.

If not, don’t worry I’m still going to define that in my own layman’s terms.Docker is the tool that allows us to set up the whole OS-level virtualization to develop and share the project in packages known as Docker Images.

In our case, it looked like as follows: For making the docker image of our project, we first have to choose a base image, most of the articles that I follow used alpine for this because it is light-weight but that seems to cause a problem in python and pip installation in my case, that’s why I choose ubuntu (more trusted and comfortable with).

And Finally, to run our program file i.e. flask_api.py automatically whenever the image is initialized we have used CMD that runs default executables.Now, just run the command given below to start building your Docker Image.

Then use sudo docker login on the command line to log in to your docker account.Then check your Image ID as described before and tag your image with the following command.After tagging simply push it on the DockerHub with the following command.From now onwards, you can simply pull your docker image with pull command.Note:- Your repo is public by default and as an unpaid user you get only one private repo.Hopefully, you have successfully built a Docker image of your Deep Learning Flask API.

Related Articles