Deploy your Machine Learning Model on Docker.
Hello, everyone in this article I am going to tell you guys about how to run Machine Learning code on the Docker container with each step.
I am using RHEL 8 as a base OS. In this OS, I have installed the Docker software and on top of the Docker, I will use the Centos image from the docker hub where I will run my ML code. So, let's get started.
Step 1: Check whether the Docker software is installed in your base OS or not. In my case, I have installed it.
How to install docker On the Linux device.
Step 2: We have to start the Docker Services.
Step 3: Pull the CentOS image from the Docker hub. In my case, I have installed it earlier so when we use the “docker images” command docker will show all the downloaded images.
Step 4: Start the Docker Container.
Step 5: So the docker container we have just launched does not come with pre-installed Python so we have to install the Python & all the python libraries that we are going to use in our ML code. In the Screenshot below it says the requirement already satisfied because I have installed it earlier.
Step 6: Now we have to create the ML code in the newly created container or we can copy the code from the Base OS to the docker container.
So I am going to copy the code from the BaseOS to the docker container. To copy the file we have a command.
“docker cp <filepath> <container ID>:<path>”
I have Created a simple basic level ML code in which it can predict marks of a student whether he/she will score on the basis of the number of hours they study. I have created the model in the /root/MLws directory
So, the first ls command is run before copying the file to show MLws directory comes after using the docker cp command.
Step 7: This is the last step in this we have to run our code.
I created a Basic ML code to show you all how to run the ML code inside the Docker container. Now, all of you know the solution.
If you learn a little bit from this article then do give a Clap & leave your comment below. This will motivate me to write more articles.
Thank You.