Publishing a Jupyter Notebook in a Docker Container
Mark Elvers
1 min read

Categories

  • jupyter

Brief notes on publishing a Jupyter notebook as a Docker container.

My starting point is a GitHub repo containing a Jupyter notebook and a requirements.txt.

git clone https://github.com/ucam-eo/tessera-interactive-map
cd tessera-interactive-map

I created a Dockerfile which pulls in a standard Python container. I used 3.11 as that is the minimum version support for https://github.com/ucam-eo/geotessera.git

pip installs the packages listed in requirements.txt plus the additional geotessera library. The extra library is noted in the README.md.

FROM python:3.11
WORKDIR /app
COPY . /app
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install git+https://github.com/ucam-eo/geotessera.git
RUN pip install jupyter
EXPOSE 8888
ENV NAME World
CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root"]

Build the Docker image.

docker build -t my-jupyter .

And run the container.

# docker run --rm -it -p 8888:8888 my-jupyter
[I 2025-07-09 16:11:37.739 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2025-07-09 16:11:37.743 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2025-07-09 16:11:37.746 ServerApp] jupyterlab | extension was successfully linked.
[I 2025-07-09 16:11:37.749 ServerApp] notebook | extension was successfully linked.
[I 2025-07-09 16:11:37.751 ServerApp] Writing Jupyter server cookie secret to /root/.local/share/jupyter/runtime/jupyter_cookie_secret
[I 2025-07-09 16:11:38.089 ServerApp] notebook_shim | extension was successfully linked.
[I 2025-07-09 16:11:38.102 ServerApp] notebook_shim | extension was successfully loaded.
[I 2025-07-09 16:11:38.104 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2025-07-09 16:11:38.105 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2025-07-09 16:11:38.107 LabApp] JupyterLab extension loaded from /usr/local/lib/python3.11/site-packages/jupyterlab
[I 2025-07-09 16:11:38.107 LabApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[I 2025-07-09 16:11:38.107 LabApp] Extension Manager is 'pypi'.
[I 2025-07-09 16:11:38.156 ServerApp] jupyterlab | extension was successfully loaded.
[I 2025-07-09 16:11:38.159 ServerApp] notebook | extension was successfully loaded.
[I 2025-07-09 16:11:38.160 ServerApp] Serving notebooks from local directory: /app
[I 2025-07-09 16:11:38.160 ServerApp] Jupyter Server 2.16.0 is running at:
[I 2025-07-09 16:11:38.160 ServerApp] http://0ad4fce9b94e:8888/tree?token=c11c0f007dd99a785ff67331514fb44e87269055952a253b
[I 2025-07-09 16:11:38.160 ServerApp]     http://127.0.0.1:8888/tree?token=c11c0f007dd99a785ff67331514fb44e87269055952a253b

Note the URL in the log output and open it in the browser. You are prompted to enter the token if you don’t specify the token as part of the URL.