Creating Machine Learning Model on Docker.

Shashwat Gaur
3 min readMay 30, 2021
Docker on Redhat Linux

Docker, an open platform for deploying apps, is much in demand presently. Reducing the time to market, docker has reduced the hustle greatly. In this article, we aim to depict how to create and run a Machine learning model.

The very initial step is to have docker installed on your system. Once your docker is installed, use “systemctl start docker” to start your docker. Then run the docker using “docker run -it — name <image name>:version, by default the version is latest. Or if you have the docker already exiting, start the docker using the “start command” and attach it using the “docker attach <dockername>”.

A docker already exists by the name of “shash.”

Now, there exist multiple ways for copying your dataset from your base OS to VM OS. To do this either use WinSCP program or simply use other methodologies to copy your file to the Linux-basedx` OS.

The other step to execute includes coying the dataset from Base OS to docker. For this, open a new terminal, and use the command “docker cp <source path> name of docker: <destination path>” Using this the dataset is copied to your docker. Now re-run your docker instance, or go to the previous terminal.

attaching existing docker

The next step would demand installing python3 on to your docker for the purpose of creating the machine learning model. For this use “yum install python3” or “dnf install python3".After the installation ends, use “pip3” command to install various python libraries including sklearn, numpy , pandas etc.

Model. py using vim editor

Now, open the vim or vi editor using “vim <filename.py>, as docker wont support the gedit command for the text editor. Import your machine learning code inside the vim or vi editor.(Here we have used a simple Linear Regression model). Now use “:wq” to save and exit.

“file created salary.pk1”

Now simply use the command “python3 <filename.py>” to execute your model. The evident result that your model has been trained and executed successfully is implied after you use the “ls command” and witness the creation of a new file with the extension that you chose while creating the model.

--

--

Shashwat Gaur
0 Followers

A tech enthusiast and an aspirer, aiming to olve real life problems, looking forward with a collaborative mindset. Planning to put the skills to best use.