Running Shiny from JupyterLab in a container

Is it possible to run a Shiny app from inside a Jupyter notebook that's running in a container?

Here's some basic code. If I run this by using Visual Studio Code and remoting into the container it works: I can navigate to the displayed URL in the browser and see the app.


However, if I try to run the same code in a notebook, using the JupyterLab interface, it fails to connect:

The image is based on the standard jupyter/datascience-notebook image from Docker Hub.

I also tried to specify a port number and open that port in the docker run command, but it didn't seem to do anything.

FWIW this isn't my preferred method of running Shiny in a container; we got a notebook from a colleague that does this, and I'm trying to make it work.