Machine Learning Model on Docker Container

Shivani Srivastava
4 min readMay 27, 2021
Image Source:docker-12–1175229.png (256×256) (iconscout.com)

Task 01

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
👉 Create a blog/article/video step by step you have done in completing this task.
👉 Submit the link of blog/article or vid

We can do this easily by following the steps which are given below:

Step1: We will change our directory using this command.

Step 2: We will create a docker repository in vim.

Step 3: Vim editor will open. Press “I” on your keyboard to bring the editor into the INSERT mode.

Step 4: Press ESC and type “:wq” OR “:x” to save the file.

Step 5: Type this command to view your repository details.

Step 6: Enter this command to install docker.

Step 7: Enable docker using this command.

Step 8: Check the status of docker using this command.

Step 9: This command will pull latest version of centos.

Step 10: To run docker container with name “LWSPTask1” I’ve used this command.

Step 11: Run this command from the base OS to check if CentOS has been mounted or not

Step 12: Run these commands to fetch from yum repo since you do not have connectivity inside docker container yet.

Step 13: Run this command to install python and ncurses.

Step 14: We will install pandas using pip library.

Step 15: We will install scikit-learn library in order to use linear regression and other functions.

All installations are successfully done.

Step 15: Create a directory in this container to store our code with the name: Task1

Step 16: Run this command base OS terminal copy the dataset from base VM to container OS.

Step 17: Create a python file and put the code you want to use to train the model.

Step 18: Create file using command vi task_model.py and insert this code.

Step 19: Run the code using command: python3 task_model.py

Step 20: Test your trained model

Task Done!

--

--

Shivani Srivastava

Project Management Enthusiast | AI Tools Junkie | Seeking Opportunities to Drive Innovation and Success