Create My Own `JupyterLab` workspace using Docker
Table of Contents
Summary #
If you develop a project involving both Python and JavaScript and you want to write some code for testing tiny logic or function in each language, you can handle and test it using JupyterLab. 🧑💻
We use Docker to create a workspace for JupyterLab, while we use it don’t need to care about any dependencies (e.g. Python, Node.js, etc.) and we can use it on any OS. 🐳
It builds and starts as a web application, so if you deploy it on an exposed server, you can access it from anywhere and also collaborate with your team. 🌐
Details #
Directory structure #
|
|
Files #
Dockerfile #
|
|
In the above Dockerfile, we use base
as a base image and install some packages from the requirements.txt
file, which should locate in the same directory as Dockerfile. You can add some packages to the file if you want.
Then, we use ijs
as a new image target and install and start the iJavascript
kernel.
In the docker-compose file below, we will use this image target.
docker-compose.yml #
|
|
In the docker-compose.yml file, we define a service named jupyter
and build an image from the Dockerfile above.
We mount the workspace volume and the jupyter server config file to the container. And also, define a network named jupyter_net
and connect the container to it.
We can handle jupyter server config using files and the command line, but I prefer to use the config file.
jupyter_server_config.py #
|
|
In the jupyter_server_config.py
file, we set the jupyter server config.
full code is here.
Run and test #
If ready to run, we can run the following command.
|
|
if you run a jupyterlab server successfully, then in your web browser, you can access the jupyter lab at http://0.0.0.0:8888/lab.
Thanks to the jupyter docker stacks 🙇, we can use the jupyter lab with the following kernels. 🎯