A full blogpost is written on this repo on my personal site here
This repository provides an easy way to Dockerize a Jupyter Lab project. Annotate your dependencies in the requirements.txt
, and then run $ docker compose up
. The output of that command will emit a URL, with a token, which you can use to access the Jupyter Lab instance in your web browser. For example, it might look like:
jupyterlab-1 | To access the server, open this file in a browser:
jupyterlab-1 | file:///home/jovyan/.local/share/jupyter/runtime/jpserver-7-open.html
jupyterlab-1 | Or copy and paste one of these URLs:
jupyterlab-1 | http://c6bcfb18cb93:8888/lab?token=somefaketoken
jupyterlab-1 | http://127.0.0.1:8888/lab?token=somefaketoken
Then you'd navigate to http://127.0.0.1:8888/lab?token=somefaketoken
or localhost:8888/lab?token=somefaketoken
in your web browser.
- You'll notice that you have one directory labeled
work
. Please be aware that only the files you write into this directory will actually be saved, as this is the only directly that is volumed into the container by ourdocker-compose.yaml
file. - If you want to install a new dependency, the easiest way is to modify the
requirements.txt
and restart the container. If that is to heavy handed, you can modify therequirements.txt
, which will set you up for future exectuions, and then access a terminal inside the Jupyter Lab instance to install the dependency for this session.
We're relying on an existing Docker image called jupyter/minimal-notebook
. This image has a slew of common features documented here. We're taking advantage of the Startup Hooks, to ensure that your Python dependencies are automatically installed for us when we spin up a container.
I've decided to leverage this image, but you can read through this documentation to select your own. Be sure to change the image
line in your docker-compose.yaml
if you want to make a modification.