JupyterLab with Python 2 and 3 kernels for Docker
10K+
Docker image for a JupyterLab instance that includes Python 2 and 3 kernels as well as associated packages required for notebook widgets.
docker pull patelravip/jupyterlab OR clone the repository and build a local image: docker build -t my-jupyter-imageMake text files with python requirements that will be installed by pip on start:
e.g., my_python2_requirements.txt and/or my_python3_requirements.txt:
requests
bs4
numpy
scipy
pandas
matplotlib
stevedore>=1.3.0,<1.4.0
following pip requirments file format.
Note: requirements can be installed from inside JupyterLab as well; this is just for set-and-forget convenience when moving JupyterLab setups around.
Run jlab_genconfig command to generate initial configuration file if you
do not already have one.
$ touch /path/to/my/new/config/file/jupyter_notebook_config.py
$ sudo chown :100000 /path/to/my/new/config/file/jupyter_notebook_config.py
$ chmod g+rw /path/to/my/new/config/file/jupyter_notebook_config.py
$ docker run --rm --log-driver=none -ti \
-v "/path/to/my/new/config/file/jupyter_notebook_config.py:/home/jupyter/.jupyter/jupyter_notebook_config.py" \
patelravip/jupyterlab jlab_genconfig
If you do not have sudo permissions, you can expose the file to all other users
instead of sudo chown ... above:
$ chmod o+rw /path/to/my/new/config/file/jupyter_notebook_config.py
Make a directory for Notebooks that is writable by a UID/GID 100000
(jupyterlab user in container):
$ mkdir /path/to/my/notebooks/directory
$ sudo chown :100000 /path/to/my/notebooks/directory
$ chmod g+rw /path/to/my/notebooks/directory
If you do not have sudo permissions, you can expose the directory to all
other users instead of sudo chown above:
$ chmod o+rw /path/to/my/notebooks/directory
Start JupyterLab on Port 8888:
$ docker run --log-driver=none \
--name my_first_lab_container \
-v "/path/to/my_python2_requirements.txt:/requirements.py2.txt" \
-v "/path/to/my_python3_requirements.txt:/requirements.py3.txt" \
-v "/path/to/my/new/config/file/jupyter_notebook_config.py:/home/jupyter/.jupyter/jupyter_notebook_config.py" \
-v "/path/to/my/notebooks/directory:/home/jupyter/Notebooks \
-p "8888:8888" \
patelravip/jupyterlab
Modify the volumes, -v, according to your requirement files, config file, and
Notebooks directory.
You should be able to access JupyterLab from your browser at the following address: http://localhost:8888/. The token for login will be provided in the log messages in the terminal after executing the command above.
If you used the link with token from the startup log, you bypassed the screen to set a password to avoid using token authentication in the future. You can still manually set a password.
Use the jupyter notebook password command to set a password that will be saved as a hash in your configuration file:
$ docker run --rm --log-driver=none \
-v "/path/to/my/new/config/file/jupyter_notebook_config.py:/home/jupyter/.jupyter/jupyter_notebook_configuration.py" \
patelravip/jupyterlab jupyter notebook password
After running the command to start your JupyterLab instance, you will now be prompted for a password instead of having to use the link or provide the randomized token from the startup log.
Often you will need to use a system executable in a python script, e.g. with
subprocess, install a package that is required by a python module, or install
a python package not available with pip but is in the Debian repositories
(base image is currently based on Debian stretch).
Use docker exec to execute commands as root in your running container:
Update the package list:
$ docker exec --user=root my_first_lab_container apt-get update
Install the desired packages (e.g., tabix and pymol)
$ docker exec --user=root my_first_lab_container apt-get -y install tabix pymol
Note: replace my_first_lab_container with the container name you set when you first
started your JupyterLab instance.
Content type
Image
Digest
Size
439.4 MB
Last updated
over 7 years ago
docker pull patelravip/jupyterlab