DEV Community

Cover image for Deploy Machine learning(ML) model in Docker container.
bhat sumair
bhat sumair

Posted on

Deploy Machine learning(ML) model in Docker container.

First we will understand what is machine learning(ML) and Docker.
Machine learning:- Machine learning is an application/program or subset of AI that allows machines to learn from data without being programmed explicitly.
Docker:-It is a tool that provides platform to create, run and deploy the applications by using containers. Docker is a bit like a virtual machine rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they're running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application.
Here are the complete steps:-
Step 1:
Install docker
#yum install docker-ce --nobest
if you have already installed check for query
#rpm -q docker-ce
Alt Text
step 2:
check status of docker
#systemctl status docker
if services are not enabled run
#systemctl start docker
Alt Text
step 3:
download the latest centos image from docker hub
#docker pull centos:latest
Alt Text
step 4:
deploy a latest centos new container
#docker run -it --name MyOs centos:latest
by passing -it arguments provides terminal and we can interact with it.
Alt Text
STEP 5:
Installing python3 on centos container
Alt Text
Step 6:
Now installing all required packages
#pip3 install numpy
#pip3 install pandas
#pip3 install sklearn
Alt Text
step 7:
copying dataset from base os to centos container
#docker cp /root/salary.csv MyOs:/ML
Alt Text
Step 8:
Code to run for ML model
Alt Text
Final Step:
#python3 model.py
Here is the complete output of our ML model
Alt Text
THANK YOU

Top comments (0)