trame+jupyterlab+docker = NS_ERROR_CONNECTION_REFUSED

I’d like to run jupyterlab with trame inside a docker container.

Following Trame and Jupyter Lab | trame I use this Dockerfile:

FROM ubuntu:24.04

RUN apt-get update -y

RUN apt-get install -y python3-pip python3-venv

RUN cd && python3 -m venv .venv && bash -c "source .venv/bin/activate && pip install trame trame-vtk trame-vuetify  setuptools jupyterlab"

RUN echo "source /root/.venv/bin/activate" >/root/.bashrc

After building an image from this Dockerfile I start a container:

docker run --rm -it -p 8888:8888 tramejupyter:1.0

Inside the container I start jupyter lab:

jupyter lab --ip '*' --allow-root --no-browser

Jupyter is usable for arbitrary python commands. But when I start the cone demo from the Trame+Jupyter intro inside jupyterlab:

from trame.app.demo import Cone
app = Cone()
app

I get some white space instead of the trame output widget, and some text “Launching …” flickered before it was overwritten by the white space.

In the Firefox debugger console I see this text:

Uncaught ReferenceError: RPMGetHostForDisplay is not defined
    getHostName chrome://global/content/aboutNetErrorHelpers.mjs:48
    <anonymous> chrome://global/content/net-error-card.mjs:31

In the Firefox debugger Network tab I see this entry:

Status: (error icon)
Method: GET
Domain: localhost:39693
File: index.html?ui=main&reconnect=auto
Initiator: subdocument
Transferred: NS_ERROR_CONNECTION_REFUSED

What is going wrong?

From the Network output “Domain: localhost:39693” I assume that a socket for port 39693 was opened, which may have been blocked, because only port 8888 was forwarded when the docker container was started.
If this is correct, who is opening this socket? Is it jupyterlab internal, or is it trame? Is it possible to force the socket to some small port range, so that I can forward those ports on the docker container?

To phrase my question more general:

Is it possible to run the cone example from the Trame+Jupyterlab intro on a docker container?

Thanks, Gregor

Because docker isolate your network, it will be simpler to also install trame-jupyter-extension to rely on the existing communication infrastructure of Jupyter rather than the one provided by trame (a different port that don’t get exposed via your docker setup).

HTH