Thicket data repository for the EEG
at main 4.6 kB view raw
1{ 2 "id": "https://www.tunbury.org/2025/07/09/jupyter", 3 "title": "Publishing a Jupyter Notebook in a Docker Container", 4 "link": "https://www.tunbury.org/2025/07/09/jupyter/", 5 "updated": "2025-07-09T00:00:00", 6 "published": "2025-07-09T00:00:00", 7 "summary": "Brief notes on publishing a Jupyter notebook as a Docker container.", 8 "content": "<p>Brief notes on publishing a Jupyter notebook as a Docker container.</p>\n\n<p>My starting point is a GitHub <a href=\"https://github.com/ucam-eo/tessera-interactive-map\">repo</a> containing a Jupyter notebook and a <code>requirements.txt</code>.</p>\n\n<div><div><pre><code>git clone https://github.com/ucam-eo/tessera-interactive-map\n<span>cd </span>tessera-interactive-map\n</code></pre></div></div>\n\n<p>I created a <code>Dockerfile</code> which pulls in a standard Python container. I used 3.11 as that is the minimum version support for <a href=\"https://github.com/ucam-eo/geotessera.git\">https://github.com/ucam-eo/geotessera.git</a></p>\n\n<p><code>pip</code> installs the packages listed in <code>requirements.txt</code> plus the additional <a href=\"https://github.com/ucam-eo/geotessera.git\">geotessera</a> library. The extra library is noted in the <a href=\"https://github.com/ucam-eo/tessera-interactive-map/blob/main/README.md\">README.md</a>.</p>\n\n<div><div><pre><code>FROM python:3.11\nWORKDIR /app\nCOPY <span>.</span> /app\nRUN pip <span>install</span> <span>--no-cache-dir</span> <span>-r</span> requirements.txt\nRUN pip <span>install </span>git+https://github.com/ucam-eo/geotessera.git\nRUN pip <span>install </span>jupyter\nEXPOSE 8888\nENV NAME World\nCMD <span>[</span><span>\"jupyter\"</span>, <span>\"notebook\"</span>, <span>\"--ip=0.0.0.0\"</span>, <span>\"--port=8888\"</span>, <span>\"--no-browser\"</span>, <span>\"--allow-root\"</span><span>]</span>\n</code></pre></div></div>\n\n<p>Build the Docker image.</p>\n\n<div><div><pre><code>docker build <span>-t</span> my-jupyter <span>.</span>\n</code></pre></div></div>\n\n<p>And run the container.</p>\n\n<div><div><pre><code><span># docker run --rm -it -p 8888:8888 my-jupyter</span>\n<span>[</span>I 2025-07-09 16:11:37.739 ServerApp] jupyter_lsp | extension was successfully linked.\n<span>[</span>I 2025-07-09 16:11:37.743 ServerApp] jupyter_server_terminals | extension was successfully linked.\n<span>[</span>I 2025-07-09 16:11:37.746 ServerApp] jupyterlab | extension was successfully linked.\n<span>[</span>I 2025-07-09 16:11:37.749 ServerApp] notebook | extension was successfully linked.\n<span>[</span>I 2025-07-09 16:11:37.751 ServerApp] Writing Jupyter server cookie secret to /root/.local/share/jupyter/runtime/jupyter_cookie_secret\n<span>[</span>I 2025-07-09 16:11:38.089 ServerApp] notebook_shim | extension was successfully linked.\n<span>[</span>I 2025-07-09 16:11:38.102 ServerApp] notebook_shim | extension was successfully loaded.\n<span>[</span>I 2025-07-09 16:11:38.104 ServerApp] jupyter_lsp | extension was successfully loaded.\n<span>[</span>I 2025-07-09 16:11:38.105 ServerApp] jupyter_server_terminals | extension was successfully loaded.\n<span>[</span>I 2025-07-09 16:11:38.107 LabApp] JupyterLab extension loaded from /usr/local/lib/python3.11/site-packages/jupyterlab\n<span>[</span>I 2025-07-09 16:11:38.107 LabApp] JupyterLab application directory is /usr/local/share/jupyter/lab\n<span>[</span>I 2025-07-09 16:11:38.107 LabApp] Extension Manager is <span>'pypi'</span><span>.</span>\n<span>[</span>I 2025-07-09 16:11:38.156 ServerApp] jupyterlab | extension was successfully loaded.\n<span>[</span>I 2025-07-09 16:11:38.159 ServerApp] notebook | extension was successfully loaded.\n<span>[</span>I 2025-07-09 16:11:38.160 ServerApp] Serving notebooks from <span>local </span>directory: /app\n<span>[</span>I 2025-07-09 16:11:38.160 ServerApp] Jupyter Server 2.16.0 is running at:\n<span>[</span>I 2025-07-09 16:11:38.160 ServerApp] http://0ad4fce9b94e:8888/tree?token<span>=</span>c11c0f007dd99a785ff67331514fb44e87269055952a253b\n<span>[</span>I 2025-07-09 16:11:38.160 ServerApp] http://127.0.0.1:8888/tree?token<span>=</span>c11c0f007dd99a785ff67331514fb44e87269055952a253b\n</code></pre></div></div>\n\n<p>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.</p>", 9 "content_type": "html", 10 "author": { 11 "name": "Mark Elvers", 12 "email": "mark.elvers@tunbury.org", 13 "uri": null 14 }, 15 "categories": [ 16 "jupyter" 17 ], 18 "source": "https://www.tunbury.org/atom.xml" 19}