Training Machine Learning Model inside Docker container
π 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
Before proceeding to the further step please ensure that Docker should be installed in the system.
To check whether the docker is installed in our system or not we can check by using the command
#docker info
Now to start the docker services we use the command #systemctl start docker.
The docker system is running on the system now we have to pull the centOS image from the Docker hub.
To pull the image we use the command
#docker pull centos:8
Now we have to create a container with the help of centOS image for that we have to use the command
#docker run -t -i centos:8
To know the name of the container running run the command
#docker ps
Now we have to install the python inside the container centos for that we have to use the command
#dnf install python3
After installing python in the container os we have to install the library of python which gonna used in creating machine learning model those commands are:-
#pip3 install numpy
#pip3 install pandas
#pip3 install scikit-learn
Till here our base environment is ready. Now, we need to get the dataset and Machine Learning model inside the docker container.
Here i have data set and machine learning model i my macOS machine so first of all we would have to transfer dataset and Machine Learning model file from macOS to RHEL Vm. since in mac the terminal is built on the Bash shell so, to do this we gonna used termial of mac for some inbuilt commands in it to transfer file from base operating system to guest operating system now the command we have to use is scp command how to use scp command is :-
scp -rp location of file to be transferred username of the guest os@ip address of the guest os :/folder in which file to be transferred
example:- scp -rp /users/rohitkumar/filename.txt root@192.168.1.36:/root
By this way we send our data set file and machine Learning model file in the RHEL8 Vm OS
Now we have the data set and the created machine Learning model file in our linux os now we have to transferred this file to docker container by using the command
#docker cp filename container name:/file name
Now create a python file on the container os through Vim editor by the command
#vi file.py
i β for insert in vim editor
then press esc then press :wq to save the program and exit
Now Create a model file.
After creating the model file itβs time to run the model file for that we have to use the command
#python3 filename.py
Now we have successfully created Model and done predictions inside a docker container.
Thatβs all
Thanks for reading.
β β β β β β β β β ******************* β β β β β β β β β