Summer 2021- Task 1

Mangal Hansdah
3 min readMay 31, 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 copy/create machine learning model which you have created in jupyter notebook.

Note: I will be using Red Hat linux as my Base machine.

Starting Docker
To start docker use this command: systemctl start docker
To check the status of Docker use command: systemctl status docker

Checking whether OS has been installed or not and Installing centos on Docker
Command to check: docker ps -a

To use the latest version of centos use this command: docker pull centos:latest

Launch Docker Image
Using this command to launch the OS which you pulled from the Docker registry: docker run -t -i <os-name> or docker run -t -i --name=<container-name> <os-name>
In our case, we have installed centos so replace <os-name> with centos. You can give your own container-name
For example: docker run -t -i --name=ml1 centos

Another way to start a Docker image is by running this command: docker start <container-name> and then docker attach <container-name>

Container
Now that we are inside the container, this means that we are basically in a different operating system(OS).
To check the information about OS use: cat /etc/os-release

Installing required packages to create ML model inside container
Python language: yum install python3

Scikit library: pip3 install scikit-learn

Pandas library: pip3 install pandas

vim module to edit files: yum install vim

Create the model
First create a model in your Host OS and then copy file to Container using the following command: docker cp <path-of-model> <container-name>:/<model-file-name>
Ex: docker cp SalaryData.csv ml1:/

Train the model
First create a csv file named SalaryData.csv using vim SalaryData.csv and enter two columns namely YearsExperience,Salary and enter values as shown below,

Next we need to train the model using command: vim model.py

Our model is to predict salary based on the person’s experience(in yrs)

🗨 THANK YOU…..

--

--