Machine Learning Model Over Docker Container

I have used Dataset: Salary_Data.csv ( Click here to get the dataset )

As we need docker so, First let us configure docker and install it in our system.

Note: I have used RHEL8 operating system. You can use Centos or Fedora also.

Step1: Configuring repository for docker

Path: /etc/yum.repos.d/

[docker_ce]
name=docker
baseurl=
https://download.docker.com/linux/centos/7/x86_64/stable/
gpgcheck=0

Step2: Installing Docker

yum install docker-ce --nobest -y

Step3: Starting Docker services and making it Permanent

#Will start docker services.
systemctl start docker
#Will make docker service permanent.
systemctl enable docker

Now, let us start the process to run the Simple Linear Regression code on the docker container. I have used centos image, to be specific centos:latest

Step1: Deploy Container

docker run -it --name ml_model centos:latest

Step2: Install necessary dependencies

  • Python Software
yum install python3 -y
  • sklearn python library
pip3 install sklearn
  • pandas python library
pip3 install pandas

Step3: Copy Salary_Data.csv Dataset into the container from the docker host

docker cp Salary_Data.csv c329c7e0d63c:/ml_ws
#Example
docker cp /home/(name)/(folder_name)/(file_name) (container_id):/(to_the_place_you_want_the_file_to_be)

Step4: Salary Predict Code

Now, Run the Code!

I have created a docker image named as rahul079/sklearn_centos , which you can just pull and run the code!

Step1: Pull the image from docker hub

docker pull rahul079/sklearn_centos:v1

Step2: Deploy container

docker run -it --name model_ml rahul079/sklearn_centos:v1

Step3: Run the Code!

cd ml_ws/
python3 model.py

Done! That Simple.

Thank You for Reading!

connect me :

--

--

--

2x Red Hat Certified Engineer | Aspiring MLOps & DevOps Engineer | Terraform | Ansible | Jenkins | AWS • GCP • Azure | OpenShift | Kubernetes | Docker | BigData

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Deep learning basics — batch normalization

Neural Networks 101 (Day 1 of the Semester, Minutes 0–5 of Class)

Sign Language Detection Using OpenPose in Colab

Image Classification using Create ML, Core ML and Vision Framework in Swift

TransCoder from Facebook AI

Logistic Regression Ins and Outs- Part 1

Watch here, incoming MLEs.

Evaluating a Machine Learning Algorithm

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rahulkumar Choudhary

Rahulkumar Choudhary

2x Red Hat Certified Engineer | Aspiring MLOps & DevOps Engineer | Terraform | Ansible | Jenkins | AWS • GCP • Azure | OpenShift | Kubernetes | Docker | BigData

More from Medium

Comparing the efficiency of Sieve of Eratosthenes implementation

Can phones successfully replace one of our natural senses?

myfinder response to image analysis, a swan swimming in a lake

Microsoft Sentinel Machine Learning (ML) based Threat Detection Rules

DolphinDB Partitioned Database Tutorial