New GitHub issue #118759 from sleekweasel:<br>

<hr>

<pre>
# Bug report

### Bug description:

I'm trying to run a webserver to examine a system's behaviour under load.

While looking at alternatives, I thought to try Python's webserver:

If I run the following, it works as expected:

    $ sh -c 'ulimit; date>date.txt ;  python3 -m http.server' &
    unlimited
    Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
    $ curl localhost:8000/date.txt
    Wed May 8 10:11:00 UTC 2024

If I try to run it within a docker container, it can't fork:

    $ docker run --detach --name pyhttp -p 8000:8000 python:3 sh -c 'ulimit ; date>date.txt ; python3 -m http.server'
    $ curl localhost:8000/date.txt
    curl: (52) Empty reply from server
    $ docker logs pyhttp

    unlimited
    ----------------------------------------
 Exception occurred during processing of request from ('172.18.0.1', 23904)
    Traceback (most recent call last):
      File "/usr/local/lib/python3.12/socketserver.py", line 318, in _handle_request_noblock
        self.process_request(request, client_address)
      File "/usr/local/lib/python3.12/socketserver.py", line 706, in process_request
        t.start()
      File "/usr/local/lib/python3.12/threading.py", line 992, in start
 _start_new_thread(self._bootstrap, ())
    RuntimeError: can't start new thread
    ----------------------------------------

I checked the versions:

```
$ python3 --version
Python 3.6.8
$ docker run python:3 python3 --version
Python 3.12.3

```

If I try the docker command with the python:3.6.8 package, everything works as expected.

If I try with 3.7 up to python:3.13.0a6  the behaviour still obtains.

### CPython versions tested on:

3.8, 3.9, 3.12, 3.13

### Operating systems tested on:

Linux
</pre>

<hr>

<a href="https://github.com/python/cpython/issues/118759">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>