So, today we are going use machine learning model in a docker container by installing the prerequisites inside the container i.e. Python and some required libraries and copy the model in the container.
Let's get started:
First we will start the Docker and download the CentOS Image in our VM. In many of my previous blogs I have installed and used docker so we are going to skip that part.
To download the Docker CentOS image run the following command:-
docker pull centos
Now we launch the Docker container by command:
docker run -it --name <container name> centos
Now, we will need the prerequisites to run our machine learning model. we install python and libraries like joblib, scikit-learn etc.
To use our model in the container we will have to train the model, whether in the base OS of our VM or somewhere else.
Now the saved model has to be copied into the docker container by using command like:
docker cp <model_name> <container_name>:/<model_name>
Then we will use the machine learning model to predict in the container.
we can see it is working fine, sane can be done for more complex machine learning models.