First, install Docker inside your machine. If you're using a Debian-based system, start by adding Docker's official GPG key through apt-get
:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
Then, add the repository into the apt
sources file:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
After that, you can install the Docker packages by running:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
By default, the docker
binary requires sudo
to run. You can change this by adding your user to the docker
group, which should have been automatically created by Docker during installation (if not, you can run sudo groupadd docker
).
sudo usermod -aG docker $USER
Make sure to log out and log back in for the changes to take effect.
You can install the latest JupyterHub image into a container by running:
docker run -d -p 8000:8000 --name jupyterhub quay.io/jupyterhub/jupyterhub jupyterhub
This will create a container named jupyterhub
, which you can check through
docker ps -a
You can also stop and start the container through docker start jupyterhub
and docker stop jupyterhub
.
To create a user in JupyterHub, spawn a root shel using:
docker exec -it jupyterhub bash
In it, create a system user by executing:
sudo useradd -m username
You can set the password of that user by
passwd username
which will prompt you for the password twice. After that, generate a config file by running:
jupyterhub --generate-config
and add the created user to that config file by appending the following lines:
c.Authenticator.whitelist = {'username'} c.Authenticator.admin_users = {'username'}
Only add the username to c.Authenticator.admin_users
if you want them to have administrator privileges.
In the root shell of the container, run:
sudo apt install gcc musl-dev python3-dev
pip install notebook
pip install jupyterlab
pip install jupyter_scheduler
The jupyter_scheduler
package helps with scheduling notebook executions like in Kaggle.