Deploying Machine Learning Model Into Docker Container

Punna Abhilash
3 min readMay 30, 2021

--

Task Description:

🎯Pull the Docker container image of CentOS image from Docker Hub and create a new container

🎯 Install the Python software on the top of docker container

🎯In Container you need to copy/create machine learning model which you have created in jupyter notebook

* To create a model and deploy into container we need to follow certain steps:

step1: we need to gather our dataset .

Salarydataset

step2: After gathering dataset we need to train our model.

Why Training model some questions arise into your mind:

✔ We know that our human brain has natural intelligence, but we are slow or agile to calculate things. whereas computers are very fast to perform calculations.

✔ So, we can give our human intelligence to machines and make them intelligent. Now machines can predict things as humans do.

✔ For training the machines, we need to give historical data or dataset and they will analyze the data and get trained .

step3: Now my model has been trained and they are ready to deploy into container.

  • check if the docker is installed or not on your VM :

$ Docker info

docker info
  • If not use this command to install docker on your VM :

$ yum install Docker-ce

  • After installing docker, use this command to download centOS image :

$ Docker pull centos:latest

  • After downloading you can use this command to verify centOS image is pulled into Docker or not:

$ docker images

  • Next use this command to launch your container:

$ docker run -it — name task1 centos:latest

centos image has launched
  • I had a created a model already i am copying my model into container :

* Now we will install python software inside docker container:

  • Installing the Necessary libraries for the Python to run model

=> pip3 install numpy
=> pip3 install pandas
=> pip3 install scikit-learn

  • Finally i am deploying my model into my app
press esc type :wq to save file
  • Now we will Run the app :

This is how i deployed my salary prediction model into my app inside the docker container .

I am new to this blog medium any suggestions from you i am happy.

Thank u guys for reading my article!!

Have a great day !!

GitHub URL : github.com/PUNNAABHILASH/lw-SummerProgram-2021

--

--