• Latest
  • Trending
A Complete Guide for Deploying ML Models in Docker

A Complete Guide for Deploying ML Models in Docker

May 31, 2022
Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025
ATC Ghana supports Girls-In-ICT Program

ATC Ghana supports Girls-In-ICT Program

April 25, 2023
Vice President Dr. Bawumia inaugurates  ICT Hub

Vice President Dr. Bawumia inaugurates ICT Hub

April 2, 2023
Co-Creation Hub’s edtech accelerator puts $15M towards African startups

Co-Creation Hub’s edtech accelerator puts $15M towards African startups

February 20, 2023
Data Leak Hits Thousands of NHS Workers

Data Leak Hits Thousands of NHS Workers

February 20, 2023
EU Cybersecurity Agency Warns Against Chinese APTs

EU Cybersecurity Agency Warns Against Chinese APTs

February 20, 2023
How Your Storage System Will Still Be Viable in 5 Years’ Time?

How Your Storage System Will Still Be Viable in 5 Years’ Time?

February 20, 2023
The Broken Promises From Cybersecurity Vendors

Cloud Infrastructure Used By WIP26 For Espionage Attacks on Telcos

February 20, 2023
Instagram and Facebook to get paid-for verification

Instagram and Facebook to get paid-for verification

February 20, 2023
YouTube CEO Susan Wojcicki steps down after nine years

YouTube CEO Susan Wojcicki steps down after nine years

February 20, 2023
Inaugural AfCFTA Conference on Women and Youth in Trade

Inaugural AfCFTA Conference on Women and Youth in Trade

September 6, 2022
  • Consumer Watch
  • Kids Page
  • Directory
  • Events
  • Reviews
Thursday, 16 July, 2026
  • Login
itechnewsonline.com
  • Home
  • Tech
  • Africa Tech
  • InfoSEC
  • Data Science
  • Data Storage
  • Business
  • Opinion
Subscription
Advertise
No Result
View All Result
itechnewsonline.com
No Result
View All Result

A Complete Guide for Deploying ML Models in Docker

by ITECHNEWS
May 31, 2022
in Data Science, Leading Stories
0 0
0
A Complete Guide for Deploying ML Models in Docker

Introduction on Docker

Docker is everywhere in the world of the software industry today. Docker is a DevOps tool and is very popular in the DevOps and MLOPS world. Docker has stolen the hearts of many developers, system administrators, and engineers, among others.

We’ll start with what Docker brings you; why you should use it in the first place. The article is chopped into parts this is because I’m trying to explain as simply as I can in order to make it accessible for as many people as possible. So now let’s go!

YOU MAY ALSO LIKE

French Telco Orange Hit by Cyber-Attack

ATC Ghana supports Girls-In-ICT Program

What is Docker?

 

When working on a team project we often have to see how each other code is running in our system, well I am sure you have ever said this statement or listened to this statement “This code is not running in my machine” or “I don’t know this is running in my computer but not running in your’s computer(another user)”. So these types of things can be fixed easily by docker.

Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime. Using Docker, you can quickly deploy and scale applications into any environment and know your code will run.

What are Containers?

 

Containers Docker| Docker

Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allow you to run many containers simultaneously on a given host. Containers are lightweight and contain everything needed to run the application, so you do not need to rely on what is currently installed on the host. You can easily share containers while you work, and be sure that everyone you share with gets the same container that works in the same way.

Why Use Containers for Machine Learning?

1. Running an ML model on the computer is an easy task. But when we want to use that model at the production stage in other systems, it’s a complex task. Docker makes this task easier, faster, and more reliable.

2. Using Docker we can easily reproduce the working environment to train and run the model on different operating systems

3. We can easily deploy and make your model available to the clients using technologies such as OpenShift, a Kubernetes distribution.

4. Developers can keep track of different versions of a container image, check who built a version with what, and also roll back to previous versions.

5. Even if our Machine Learning application is down, repairing, or updating, it will not stop running.

6. Our machine learning model is usually written in a single programming language such as python but the application will certainly need to interact with other applications written in different programming languages. Docker manages all these interactions as each microservice can be written in a different language allowing scalability and the easy addition or deletion of independent services.

How to Deploy the ML Model Inside a Docker Container?

Let us understand how to deploy our Machine Learning model inside a Docker container. Here, I will take a simple Titanic dataset Machine Learning model to illustrate the workflow.

1. Create a separate directory for this task and copy your Machine learning code to that directory.

2. Create a Dockerfile.

What’s a Dockerfile?

It’s just a way to create your own customized Docker image. This file contains step-by-step requirements as per our use case. Simply Dockerfile is a script on a recipe for creating a Docker image. It contains some. special keywords such as FROM, RUN, CMD, etc.

Dockerfile is dynamic in nature. It means at any point in time if you want to change any stop, update or add anything, you can just add & build. That’s quick & time-saving.

What's a Dockerfile?| Docker

Now let us understand the code inside Dockerfile

FROM This is used for providing the name of the base image on which we’ll be adding our requirements. Here, I have used Python as a base image for the container.

COPY command will copy the specified files from the local machine to the container that will be launched using this image.

RUN it’s a build time keyword, & any program that goes with it will be executed during the building of the image.

CMD It’s a runtime keyword. Any program one command goes with it will be executed when the container is launched.

NOTE: In Docker or Container world, we launch a specific container for a specific program or process only. So after it is Executed completely – we don’t need the environment Hence we can conclude the life of the process=Life of the container

Entrypoint and CMD, both can be used to specify the command to be executed when the container is started. The only difference is that ENTRYPOINT doesn’t allow you to override the command. Instead, anything added to the end of the docker RUN command is appended to the command.

 3. Python Code

This python code will be run when as soon as our container start. Here I have used the joblib module in python through which we can save and load our trained models.

import joblib


classifier = joblib.load('survive_prediction.pkl')
print("Enter the following details to make the predictions:- n")


pclass = int(intput("Enter The Pclass:- "))
Age = int(intput("Enter The Age:- "))
SibSP = int(intput("Enter The SibSp:- "))
Parch = int(intput("Enter The Parch:- "))
Sex = int(intput("Enter The Sex:- "))

passenger_prediction = classifier.predict([[pclass,Age,SibSP,Parch,Sex]])

if passenger_prediction == 0:
print("Not Survived.")
else ;

print("Survived")

4. Now, we will going to build the image from the Dockerfile that we have created just above.

To build the image we use the following command.

docker build -t image_name:version .

Dockerfile Python Script| Docker

5. Now Finally, we are ready to launch our container and run our machine learning model

docker run -it –name titanic_survivers titanic_model:v1

-> When we run this command, a new environment is launched; a new OS entirely. So behind the scene, docker-engine does a lot of tasks such as providing network card, storage, complete new file system, RAM/CPU, etc. These are with respect to an OS.

->So if you want to see the entire details of the container you can use

docker info container_name

-> With this command, you can see the entire details of the container like, how much storage it is using, what’s the network card and many more.

Script 1 Docker

6. Using CLI(Command Line Input) we can give input to our python code.  By command-line input means through the keyboard we can pass input to the container.

Script 2| Docker

Conclusion

I hope now you have some understanding of how to deploy your model inside the docker/ containerize model in docker. Still, we’ve only scratched the surface when it comes to all of the benefits Docker has to offer.

  • It is a software platform that allows you to build, test, and deploy applications quickly.
  • It provides the ability to package and run an application in a loosely isolated environment called a container
  • Running an ML model on the computer is an easy task. But when we want to use that model at the production stage in other systems, it’s a complex task. It makes this task easier, faster, and more reliable.
  • In order to create a docker image, we use a docker file.
  • The docker file is just a way to create your docker image.
  • “docker build -t image_name:version .” Is used to build your own custom image using docker.
  • “docker run -it –name container_name image_name:version”. Is used to start the container.
  • Using CLI(Command Line Input) we can give input to our python code. By command-line input means through the keyboard we can pass input to the docker container.
Source: Parth Singh
Tags: A Complete Guide for Deploying ML Models in Docker
ShareTweet

Get real time update about this post categories directly on your device, subscribe now.

Unsubscribe

Search

No Result
View All Result

Recent News

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025
ATC Ghana supports Girls-In-ICT Program

ATC Ghana supports Girls-In-ICT Program

April 25, 2023

About What We Do

itechnewsonline.com

We bring you the best Premium Tech News.

Recent News With Image

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025

Recent News

  • Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa July 29, 2025
  • French Telco Orange Hit by Cyber-Attack July 29, 2025
  • ATC Ghana supports Girls-In-ICT Program April 25, 2023
  • Vice President Dr. Bawumia inaugurates ICT Hub April 2, 2023
  • Home
  • InfoSec
  • Opinion
  • Africa Tech
  • Data Storage

© Copyright 2026, All Rights Reserved | iTechNewsOnline.Com - Powered by BackUPDataSystems

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist

No Result
View All Result
  • Home
  • Tech
  • Africa Tech
  • InfoSEC
  • Data Science
  • Data Storage
  • Business
  • Opinion

© Copyright 2026, All Rights Reserved | iTechNewsOnline.Com - Powered by BackUPDataSystems

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
Go to mobile version