Using Machine Learning programs inside Docker

Photo by Florian Olivo on Unsplash

Pull a docker container image of centOS from Docker Hub

Install Python on centOS

In the container creating or using premade machine learning model.

  • Install Docker on the system to pull to successfully pull the image.

To check whether it is installed or not by use command docker info

  • Initialize the docker using systemctl start docker

Pull image using docker pull centos:8

Now, create a container using the command docker run -t -i centos:8

You have entered the containerized OS now.

  • To see the info of os running in docker use command docker ps

Here is the info of the os running on my Docker :-

Installation of Python

  • To install python over centOS use command dnf install python3

Also installing somelibraries of python which are helpful in machine learning i.e.

  • pip3 install numpy
  • pip3 install pandas
  • pip3 install scikit-learn

You can now check if these 3 libraries installed using help(“modules”) in python.

Transfer the file containing your machine learning model to the container using the command docker cp file_name frosty_rubin:/file_name

Now, run the python commands to run your trained model

  • import.joblib
  • var_name=joblib.load(‘file_name’)

Now that the model has been fetched we can now predict about the future results of your dataset using var_name.predict()

Thank you for Reading…..