Deploying Machine Learning Model on Docker Container

Sanchita Agrawal
3 min readJun 12, 2021

Hello Guys😊

I’ve come up with a new blog. Here I’m going to tell you how you can run your ML code on the top of Docker Container with Base OS RHEL8.

🔰Highlights of this blog🔰

👉 Pull the Docker container image of CentOS image from DockerHub 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

If you have already installed then good to go further. In my case I have already installed so let’s move further.

📍To check docker in your system by command : rpm -q docker-ce

📍Start the docker services by running commands:

systemctl start docker

systemctl status docker

📍Now pull centos image on docker and check by command:

docker pull centos

docker images

📍Start the docker container by command docker run -it centos:latest

📍Docker doesn't comes with pre-installed software. So, you need install it. Here we install python with command yum install python3 and all the python modules we need for our machine learning model to get trained by command pip3 install scikit-learn and others.

📍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/ name>:<path>”

Here I have made a MLws directory in my BaseOS i.e. RHEL8 and by using WinSCP I have transferred my python program code (main_marksapp.py) and my saved model (marks.pk1) in this directory. I just copied both folder in my docker container mlos using command I mentioned above.

📍Now run the python3 code in docker container and get the required results.

This is how you can easily deploy your machine learning model and get results..!!

Thankyou !😊

--

--

Sanchita Agrawal
0 Followers

Computer Science Major || Software Developer@GenusPower