docker容器中执行pip安装命令报RuntimeError: can't start new thread

在docker容器中执行pip3 install numpy报错

  File "/usr/lib/python3.10/threading.py", line 935, in start
    _start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread

经搜索到一文,

ubuntu:21.10 and fedora:35 do not work on the latest Docker (20.10.9)

This is because the default seccomp profile of Docker 20.10.9 is not adjusted to support the clone() syscall wrapper of glibc 2.34 adopted in Ubuntu 21.10 and Fedora 35.

排查出错的容器,是FROM ubuntu:22.04,再看docker版本,确实是20.10.9。Docker 20.10.9的默认seccomp配置文件没有调整为支持Ubuntu 21.10和Fedora 35中采用的glibc 2.34的clone3()。

临时的解决方案:可以让安装时不报错,但实际运行时不一定不报错。

pip config --user set global.progress_bar off

推荐的解决方案:将Docker升级到20.10.10或更高版本。