✴️Creating ML Model inside Docker Container …!! 🐋

Ankita Patil
3 min readMay 27, 2021

† † † † † † † † † † † † † † † † † † † † †† † † †† † † †† † † †† † † †† † † †† † † †

💫 What is Machine Learning ?

👉 Machine learning (ML) is the concept in which machine can learn new things like human beings…,by giving power of intelligence to it. And that power is given by a programmer to the machine.

💫 What is Docker..?

👉 Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers are isolated from one another and bundle their own software, libraries and configuration files, they can communicate with each other through well-defined channels.

Task Description … 📃

➡️ Pull the Docker container image of CentOS image from Docker Hub and create a new container
➡️ Install the Python software on the top of docker container

➡️ In Container you need to deploy machine learning model

Let’s Start ….😃🙌
Step 1: Install Docker

I] Configure yum for Docker :

Create a file “/etc/yum.repos.d/docker.repo”[docker]name=docker repo
baseurl=https://download.docker.com/linux/centos/7/x86_64/stable/
gpgcheck=0

When it’s done.., verify by “yum repolist". You see some more software.

II] Install Docker and start service :

# Install Docker

yum install docker-ce -- noblest -y
Then…

# To start docker service

systemctl start docker

# To enable docker service

systemctl enable docker

Step 2: Pull centos image

docker pull centos:latest

Step 3: Launch a container

docker run -it - -name <name_of_OS> centos: latest

Step 4: Install Python36

yum install python36
# Install required libraries

pip3 install pandas

pip3 install scikit-learn

Step 5: Create a Docker image with commit

docker commit <os_name> <image_name>:<version>

Step 6: Launch a container using that image

docker run -it --name<name><image_name_: version>

To verify use “docker images" command

docker images

Step 7: Copy the dataset which we want to work on

```docker cp<location_in_local> <docker_os_name>:<location_in_docker_container>

To verify is it copied or not check inside the docker container

ls

Step 8: Create Linear Regression Model

Step 9: Let’s check our model
The output of our machine learning model is

Thanks for Reaching here…,

🌈 Keep Learning and Keep Sharing…😃✌️

--

--