Deploying Machine Learning Model on top of Docker Container

Aditya Pande
2 min readMay 27, 2021

Task Description:-

👉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.


First of all, you should have Docker installed in your OS. In my case, I am using RHEL version 8. After installing Docker, start its service using command->

systemctl start docker

Now, we have to pull or we can say install CentOS Image in our RHEL8 BaseOS. For doing this, use command->

docker pull centos:latest

Here, I am downloading the latest version of CentOS and “pull” command by default downloads from public repository of Docker which contains all types of simple and customized images called as “Docker Hub”.

To check whether image is installed or not, we can use command->

docker images


After downloading CentOS image, we have to launch one container from CentOS image using command->

docker run -it --name= <cont_name> centos:latest

Now, we will install Python interpreter on top of docker container using command->

yum install python36 -y


Now, I have already transferred model I bulit on my Jupyter Notebook in my RHEL8 OS. You can refer video for the code. To copy this model (.pk1) file in docker container, use command->

docker cp <model> <cont_name>:<destination>

If we want to load this package in our container, we have to install joblib library and in order to load and execute the code we have written we have to install another library called scikit_learn.

pip3 install joblib

pip3 install scikit_learn

Now, we will write code in python which will load this file and then predict the output for us. Refer below video.

Thank You Vimal Daga Sir for giving such a wonderful task from which we learned a lot.