Creating Machine Learning Model on Docker Container

Ashish Dwivedi
3 min readMay 30, 2021


In this blog, we will be discussing how we will be creating a machine learning model in a Docker Container and using the model for some predictions. For the task, we will be creating a fundamental machine learning model which can predict height of son according to their father’s height.

First, we need to have Docker installed inside our Linux Operating. Here I am using RedHat Linux, so we need to configure yum to install docker. We need to create a .repo file inside our /etc/yum.repos.d/. We have created a file docker.repo, and then inside the file, we have configured the repo. You can see the below image for the same.

# yum install docker  --nobest# systemctl start docker# systemctl enable docker

These command will install docker and will start docker service and enable it permanentaly.

# systemctl status docker
docker run -it --name Ml centos 

After runing this command we will land on our docker os

Now we have to install python3 library

docker cp <file name> osname:path

By runing this command we will copy all the files in our docker container.

For running our ML code we need some libraries first we have to install pip3

#yum install python3-pip -y#pip3 install pandas#pip3 install sckit-learn#pip3 install joblib

Now we will run our linear regression code and this will create model and store model in file

Now this file we will use in our python code where we will take input from the user to predict height.

when we run we will get output like this.

Happy Coding………..

github url