Deploying a Jupyter Notebook App
Introduction
Jupyter Notebook lets you run interactive Python notebooks with rich outputs. Deploying Jupyter with a Dockerfile on Klutch.sh provides reproducible environments, managed secrets, and persistent storage for notebooks and data—all configured from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, and best practices for secure notebook access.
Prerequisites
- A Klutch.sh account (create one)
- A GitHub repository with your notebooks and dependencies (GitHub is the only supported git source)
- Docker familiarity and Python 3.10+ knowledge
- Optional: GPU-enabled runtime if you plan to use CUDA-accelerated workloads
For platform onboarding, see the Quick Start.
Architecture and ports
- Jupyter serves HTTP; set the internal container port to
8888. - If you run supporting databases or caches, deploy them as separate Klutch.sh TCP apps exposed on port
8000and connect on their native ports. - Persistent storage is recommended for notebooks, data, and virtual environments.
Repository layout
jupyter-notebook/├── notebooks/ # Your .ipynb files (mount as volume)├── requirements.txt # Python dependencies├── start.sh # Launch script├── Dockerfile # Must be at repo root for auto-detection└── .env.example # Template only; no secretsKeep secrets out of Git; store them in Klutch.sh environment variables.
Installation (local) and starter commands
Install dependencies and run locally before pushing to GitHub:
python -m venv .venvsource .venv/bin/activatepip install -r requirements.txtjupyter notebook --ip=0.0.0.0 --port=8888 --no-browserOptional helper start.sh for portability and Nixpacks fallback:
#!/usr/bin/env bashset -euo pipefailpython -m venv .venvsource .venv/bin/activatepip install -r requirements.txtexec jupyter notebook --ip=0.0.0.0 --port=8888 --no-browserMake it executable with chmod +x start.sh.
Dockerfile for Jupyter Notebook (production-ready)
Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt /app/requirements.txtRUN pip install --no-cache-dir -r requirements.txt
COPY . /app
ENV PORT=8888
EXPOSE 8888CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--NotebookApp.token="]Notes:
- For GPU, switch to a CUDA-enabled base image compatible with your dependencies.
- Set a secure token or password in production; the example disables token for simplicity.
Environment variables (Klutch.sh)
Set these in the Klutch.sh app settings (Secrets tab) before deploying:
PORT=8888NOTEBOOK_DIR=/app/notebooksJUPYTER_TOKEN=<secure-token>(recommended)PYTHONUNBUFFERED=1
If you deploy without the Dockerfile and need Nixpacks overrides:
NIXPACKS_BUILD_CMD=pip install -r requirements.txtNIXPACKS_START_CMD=jupyter notebook --ip=0.0.0.0 --port=8888 --no-browserNIXPACKS_PYTHON_VERSION=3.11
These keep Jupyter compatible with Nixpacks defaults when a Dockerfile is absent.
Attach persistent volumes
In Klutch.sh storage settings, add mount paths and sizes (no names required):
/app/notebooks— required for notebooks and outputs./app/.venv— optional if you want to persist the virtual environment./app/data— optional for datasets or checkpoints.
Ensure these paths are writable inside the container.
Deploy Jupyter Notebook on Klutch.sh (Dockerfile workflow)
- Push your repository (with the Dockerfile at the root) to GitHub.
- Open klutch.sh/app, create a project, and add an app.
- Connect the GitHub repository; Klutch.sh automatically detects the Dockerfile.
- Choose HTTP traffic for Jupyter.
- Set the internal port to
8888. - Add the environment variables above (including a secure token and any
NIXPACKS_*overrides if you temporarily deploy without the Dockerfile). - Attach persistent volumes for
/app/notebooks(and/app/.venvor/app/dataif used), selecting sizes that fit your workload. - Deploy. Your Jupyter Notebook server will be reachable at
https://example-app.klutch.sh; attach a custom domain if desired.
Health checks and production tips
- Use a reverse proxy health check on
/api/statusor similar. - Enforce HTTPS at the edge; forward HTTP to port 8888 internally.
- Set strong tokens/passwords; avoid disabling authentication in production.
- Monitor volume usage for notebooks/data and resize before they fill.
- Keep dependencies pinned and test with the Docker image for reproducible environments.
Jupyter Notebook on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage, and flexible HTTP/TCP routing. With the Dockerfile at the repo root and ports set to 8888 for the app (8000 externally for any TCP companions), you can deliver secure, collaborative notebooks without extra YAML or workflow overhead.