How to load a Machine Learning model in Docker

Docker is a software platform for building applications based on containers — small and lightweight execution environments that make shared use of the operating system kernel but otherwise run in isolation from one another. While containers as a concept have been around for some time, Docker, an open source project launched in 2013, helped popularize the technology, and has helped drive the trend towards containerization and microservices in software development that has come to be known as cloud native development.

We will be performing below mentioned steps to load a machine learning model on Docker:

  1. Create container with the help of centos image.
  2. Install the Python software on the top of docker container.

4. Install the required Python packages on the top of docker container.

5. Now inside this container we need to copy/create our machine learning model on whichever dataset we want.

6. Create model file.

7. Run your model.

Step 1: Pull the Centos Image from Dockerhub.

“docker pull centos:latest”

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

“docker run -i -t — name=container_name centos:latest”

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

“yum install python3”

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

“pip3 install numpy”

“pip3 install pandas”

“pip3 install scikit-learn”

Step 5 : Now inside this container we need to copy/create our machine learning model on whichever dataset we want.

“ docker cp salary_data.csv ml:/salary_data.csv”

Step 6 : Create a predict.py file.

Step 7 : Run the model.

THANK YOU!

--

--

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