Docker Image: Jupyter Crash

Hi,
My first post here, hope to receive some help.
I have tried various ways to get fenics to run on an ubuntu system. (conda, apt, apt-get). While I was partially successful, I failed to get complex mode to work (I think).
So I decided that the most foolproof way to proceed is to use the docker image, since there are clear instructions how to switch complex mode on and since everything else should be set up correctly.

Sadly, jupyter-lab seems broken in the docker image(s). I have tried both stable and nightly docker images as well as v0.6.0.

I can start the container, navigate to jupyter but as soon as I try to create a new notebook or console, the server crashes. The last lines of the console output is below.

I have run jupyter in docker containers many times before and have not encountered this problem so far. I very much hope that its OK I ask this here althought it might be connected to jupyter issues.
Thank you very much for any pointers!

(I have edited and shortened the console output to remove the links. As a new user here, i am not allowed to post more than 2 links.)

[E 2023-03-11 14:27:12.697 ServerApp] Uncaught exception GET /api/nbconvert?1678544832543 (172.17.0.1)
    HTTPServerRequest(protocol='http', host='[REDACTED]', method='GET', uri='/api/nbconvert?1678544832543', version='HTTP/1.1', remote_ip='172.17.0.1')
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/dist-packages/tornado/web.py", line 1713, in _execute
        result = await result
      File "/usr/local/lib/python3.10/dist-packages/jupyter_server/services/nbconvert/handlers.py", line 40, in get
        exporters = await run_sync(base.get_export_names)
      File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 31, in run_sync
        return await get_asynclib().run_sync_in_worker_thread(
      File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 918, in run_sync_in_worker_thread
        worker.start()
      File "/usr/lib/python3.10/threading.py", line 935, in start
        _start_new_thread(self._bootstrap, ())
    RuntimeError: can't start new thread
[W 2023-03-11 14:27:12.697 ServerApp] wrote error: 'Unhandled error'
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/dist-packages/tornado/web.py", line 1713, in _execute
        result = await result
      File "/usr/local/lib/python3.10/dist-packages/jupyter_server/services/nbconvert/handlers.py", line 40, in get
        exporters = await run_sync(base.get_export_names)
      File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 31, in run_sync
        return await get_asynclib().run_sync_in_worker_thread(
      File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 918, in run_sync_in_worker_thread
        worker.start()
      File "/usr/lib/python3.10/threading.py", line 935, in start
        _start_new_thread(self._bootstrap, ())
    RuntimeError: can't start new thread
[E 2023-03-11 14:27:12.698 ServerApp] {
      "Host": "[REDACTED]",
      "Accept": "*/*",
      "Referer": "[REDACTED]",
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36"
    }
[E 2023-03-11 14:27:12.698 ServerApp] 500 GET /api/nbconvert?1678544832543 (1e6c2fddfc4244f1bcbd2f78545e6d0b@172.17.0.1) 16.67ms referer=[REDACTED]
[I 2023-03-11 14:27:17.594 ServerApp] Creating new notebook in 
[I 2023-03-11 14:27:17.655 ServerApp] Saving Untitled.ipynb
[I 2023-03-11 14:27:17.673 ServerApp] Writing notebook-signing key to /root/.local/share/jupyter/notebook_secret
Operation not permitted (src/thread.cpp:269)```

For anyone to be able to help you, you need to actually post how you started the jupyterlab docker image.
For instance, if I run:

docker pull dolfinx/lab:nightly
docker run -ti -v $(pwd):/root/shared -w /root/shared -p 8888:8888 --rm --shm-size=512m dolfinx/lab:nightly

I cannot reproduce your issue

Thank you very much for the quick response.
I am trying to start it woth the command that is in the documentation:
docker run --init -ti -p 8888:8888 dolfinx/lab:stable
I have just tried the command you provided (incl rebuilding) and run into the same issue.

Good to know but worrying that you cannot reproduce this behavior.

(EDIT: I just double checked: I am able to run other jupyter instances from other docker containers I am using.)

What is the system you are running your code on (what kind of architecture), and what operating system?

Could you try the following image:

 ghcr.io/fenics/dolfinx/lab:nightly

It could be related to something similar to: Cannot use jupyter notebook in the latest docker image (qemu-v6.1.0) · Issue #62 · tonistiigi/binfmt · GitHub

Thanks for all your help. I just found this: multithreading - Python in docker – RuntimeError: can't start new thread - Stack Overflow
Will try updating docker next.
System info:

 patrik@patrik  cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
 
patrik@patrik   docker --version
Docker version 19.03.5, build 633a0ea838
 
patrik@patrik   hostnamectl
   Static hostname: patrik
         Icon name: computer-desktop
           Chassis: desktop
  Operating System: Ubuntu 18.04.3 LTS
            Kernel: Linux 4.15.0-167-generic
      Architecture: x86-64

Updating docker solved it! Thanks for taking the time to help though!

sudo apt-get update
sudo apt-get upgrade docker-ce

I would in general advice you to upgrade your operating system, as Ubuntu 18.04 is quite old now and reaches its end of standard support soon: April 30, 2023
https://wiki.ubuntu.com/Releases

Thanks, of course you are right and sorry to bother the forums with problems that have that root cause probably…