How to create a Machine Learning model inside Docker container?

Hello guys in this blog I will be telling you how we can create and run a Machine Learning model inside a docker container.

First of all, we need to install Docker we can do this by the following command

yum install docker -ce — nobest -y

once the docker is installed completely we are ready to pull a container image. but before that we have to start the docker using the following command:

system start docker

to make the service permanent we use this command:

system enable docker

As the docker has now started, we are ready to pull an image.

pulling an image basically means installing an os inside docker.

In this tutorial, we are going to pull centos os using docker. For that we need to run this command:

docker pull centos

once the os is installed we need to start it and for this, we use the following command:

docker run -it — name yourOsname(anyname you want) centos

Now we are in a brand new os inside a docker container. Here we can perform all the tasks which we are able to perform in any regular Linux os.

As this is a brand new os so it does not have any software installed in it. So we have to install all the software here again according to our needs. But as this is a docker container it has some advantages like it already has yum installed and configured so there is no need to configure it again here and we can easily use yum commands to install various software.

Now, first of all, we need Python to run any machine learning model and for that, we have to install it first. So we can install python here by using this command:

yum install python3

In the above image, we can see that now python has been installed with all its dependencies. Now we are all set to write our Python code for Machine Learning Model. So we are going to create a file inside this os using vim and in that, we are going to write our code for the model and afterward, we will run that file using python3.

As of now, we have successfully created a new file with ML code inside it. You can see the code for the model in the above image. I have used a dataset for making my model learn and I have imported that dataset to this new container from rhel8 using this command:

docker cp <dataset_file_name><container>:<src-path> <local-dest-path>

now we are all set to run our las t command which is to run our pyhton file.

python3 <file_name>

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Introducing Yugabyte Platform on Azure — Beta Release Announcement — The Distributed SQL Blog

Simplifying Android Augmented Images

I tried Google’s new Python fuzzer: Atheris

Better Enhanced Repository Pattern Implementation in .NET C#

Implement a better enhanced Repository Pattern in DotNet (.NET) CSharp (C#) following best practices With Throttling/Paging, Dependency Injection (DI), Inversion of Control (IoC). Best Practice Code Coding Programming Software Development Architecture Engineering

VulnHub: symfonos: 1

Add SmartBCH RPC on Metamask in Yandex

January Updates and Recap; The smooth journey

Keywords, Identifiers, Variable & Constants in C.

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
Ansh Kumar Dev

Ansh Kumar Dev

More from Medium

CS373 Spring 2022: Sahran Hashim

Can Deep Reinforcement Learning beat PACMAN?

Leveraging technology to streamline periodic revalidation: is automation the answer?

Explaining machine learning models to business users using BigQueryML and Google Data Studio