Deploying Machine Learning Model On Docker
If you all want to know that ,“How can we run our machine learning code on docker ”. Then stick with me till the end , we’ll find it out . :)
I will divide this whole process in steps , so that it will be easy .
Step 1: Pull the Docker container image of CentOS image from DockerHub and create a new container
For this we have a Command , “docker pull centos:latest ” . This command goes to dockerhub and get us the Centos image .
Step 2: Launching container with from the centos image.
Now we will launch a container from the centos image we have downloaded from the dockerhub
for this our command is “docker run -it centos:8” here -i stands for interactive and t stands for terminal these both help us to directly enter in the container we have launched .
Step 3: Install the Python software on the top of docker container
For running Machine learning code we need python in our container .
command for downloading python “
Step 4: we will be needing some libraries for running our ML code
So i downloaded two libraries name pandas and sklearn
command for downloading them “ pip3 install pandas” “pip3 install sklearn”
Step 5: Copying data set from main OS to docker container
for this command we use “ docker cp /root/Salary_Data.csv mymlos:/”
this command is “ docker cp ‘path/filename’ ‘container name or ID:path or location where we want our file’ ”
Step 6: ML code
I have created a file “ vi LR.py ” in same location where our data set has been copied . Here is the code.
Step 7: Execution
For testing we run our python code “ python3 LR.py ” and take input from user for eg. in this I have entered value 1 .
Thankyou everyone : )