Creating Machine Learning model inside Docker Container

Shivangi Kesharwani
3 min readMay 27, 2021

Task 01:-

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
🎯Create a blog/article/video step by step you have done in completing this task.

Hello !!

This is the article, In which I am going to tell you how to run a machine learning salary prediction model inside the Docker container. we are going to set up docker and create machine learning code over there.

Step1. Create a yum repo file

First we all have to install docker in our RHEL8 Operating System, we have to create a separate repository in /etc/yum.repos.d folder, with .repo extension. Here I’ve given name docker.repo

Now, Inside that repo you have to give a url for Docker for the yum who can find the software as per the system requirements code is [docker] baseurl=https://download.docker.com/linux/centos/7/x86_64/stable name=docker gpgcheck=0

Step 2. Run the command to check the repo is correctly configured : #yum repolist

Step 3. Install Docker cmd

Step 4. To check services of Docker

Now check the #docker info

Step 5. Pull the image named centos

Step 6. Creating container : This is are our Docker host terminal which we are working after creating a container we will move inside the container .

Step 7. Now Install Python software inside the Docker container

Step 8. Now We will Install python libraries using pip3 command this is how you all can install all the required libraries like here we need pandas, numpy, sklearn, scikit-learn and joblib to created model

Step 9. Copy the files from the base OS to the container

# docker cp <source-path> <container>:<destination-path>

Step 10: Now we will create python file using cmd vi <file name.py>and will write Python Code to train the model

Step 11. Run the model

python3 <file_name>.py

This is how I successfully created salary prediction model inside the docker container.

Thanks for Reading this article!!😊

--

--

Shivangi Kesharwani

Hello!.. I’m fascinated by technology and enjoy learning and exploring it. I hope you find my information useful.