5
Mar
2023
Instructions for setting up Jupyterhub and Jupyterlab with Docker in Windows
- Download and install Docker Desktop:
- https://docs.docker.com/desktop/install/windows-install/
- WinKey +R:
- powershell
- run a jupyterhub container:
- docker run -it -p 8000:8000 –name jhubcontainer -v C:\folder_1:/home -v C:\folder_2:/srv/jupyterhub jupyterhub/jupyterhub bash
- update:
- apt update
- install python and necessary packages:
- apt-get install npm nodejs python3 python3-pip git nano
- install jupyterhub and jupyterlab:
- python3 -m pip install jupyterhub notebook jupyterlab
- install nodejs:
- cd configurable-http-proxy
- npm install
- Use ‘npm install -g’ for global install
- install native authenticator:
- cd /home
- git clone https://github.com/jupyterhub/nativeauthenticator.git
- cd nativeauthenticator
- pip3 install -e .
- generate jupyterconfig
- mkdir /etc/jupyterhub
- cd /etc/jupyterhub
- jupyterhub –generate-config -f jupyterhub_config.py
- edit the jupyterhun config file:
- nano jupyterhub_config.py
- Copy and Paste the following script:
import pwd, subprocess
c.JupyterHub.authenticator_class = 'nativeauthenticator.NativeAuthenticator'
c.Authenticator.admin_users = {'admin'}
c.Authenticator.allowed_users = {'other_user_name'}
def pre_spawn_hook(spawner):
username = spawner.user.name
try:
pwd.getpwnam(username)
except KeyError:
subprocess.check_call(['useradd', '-ms', '/bin/bash', username])
c.Spawner.pre_spawn_hook = pre_spawn_hook
c.Spawner.default_url = '/lab'
- run jupyterhub
- jupyterhub -f /etc/jupyterhub/jupyterhub_config.py
- On a chrome tab open:
- Sign up as “admin” and create password
- Sign up other user accounts
- Login as admin and go the authorize window to authorize other users:
- The following command will spawn a root shell in your docker container. You can use the root shell to create system users in the container.:
- docker exec -it jhubcontainer bash
Useful Links:
- https://github.com/jupyterhub/jupyterhub
- https://hatarilabs.com/ih-en/how-to-set-a-multiuser-jupyterlab-server-with-jupyterhub-in-windows-with-docker
- https://www.npmjs.com/package/configurable-http-proxy?activeTab=readme