In this article, we are going to see how to run/launch the Jupyter notebook inside the docker container.
By default, we cant run any GUI applications on Docker container. By performing some trick, we are going to run those applications inside the docker container.
We have to know our GUI Display variable of our localhost by running the following command.
echo $DISPLAY
Here, DISPLAY variable is :0
Then we have to create the docker container by using following command.
docker run -it --name mygui --net=host --env="DISPLAY" -v /root:/root centos:latest
Here, we are giving docker network as host network in order to reach the host and access the host environment, since we are going to use host's Graphical Interface to run the GUI applications on Docker containers.
We are importing a environmental variable DISPLAY in order to get that display to run GUI applications.
Now, you are inside the Docker container. But, you may notice that your hostname on bash is not changed.
You can also verify using your IP or running any non-default applications.
Next step is to install firefox and Python3, because Jupyter is a python library so we required Python and Jupyter runs on the top of firefox.
You can install those packages using the following command.
yum install firefox python3 -y
After installing those packages, final step is to install Jupyter using pip3 by using following command.
pip3 install jupyter
Now, your Jupyter library is installed. You can use it by running the following command.
jupyter notebook --allow-root
Since, due to security concern, Jupyter cant run in root mode.So, we add --allow-root in order to launch Jupyter in root mode.
Finally, we launch Jupyter notebook inside the container. Now, you can run any ML models on Jupyter.
Thats it. Thank you for your reads. Stay tuned for my upcoming article!!
Top comments (0)