Load A Machine Learning Model Inside The Docker Container

Raja Sharma
3 min readMay 27, 2021

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 train machine learning model.

What is Docker?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.

What is Machine Learning?

Machine learning is a branch of artificial intelligence that includes methods, or algorithms, for automatically creating models from data. Unlike a system that performs a task by following explicit rules, a machine learning system learns from experience. Whereas a rule-based system will perform a task the same way every time (for better or worse), the performance of a machine learning system can be improved through training, by exposing the algorithm to more data.

Pre-requisites:

  • Linux[here RHEL is used ]
  • Docker installed in your system

Step 1: Pull the Centos Image from DockerHub.

cmd-“docker pull centos”

Step 2 : Create container with the help of centos image.

cmd- docker run -it — name=container_name centos

Step 3 : Install the Python software on the top of docker container.

cmd- yum install python3

Step 4: Install the required Python libraries on the top of docker container.

cmd- pip3 install pandas numpy scikit-learn

Step 5 -create/copy/link ML model on the top of docker container.

For see the code of ML model

cmd- vi <ML_mode_file_name>

Step 6: Let’s Test

cmd- python3 <filename>

Thanks for Reading !!

--

--