odoo/docker

RuntimeError: can't start new thread

wasdik opened this issue · 5 comments

wasdik commented

Just trying to run Odoo 17. But i get an error. What could be the reason?

Logs:

2023-12-13 15:10:40,679 1 INFO ? odoo: Odoo version 17.0-20231208
2023-12-13 15:10:40,679 1 INFO ? odoo: Using configuration file at /etc/odoo/odoo.conf
2023-12-13 15:10:40,679 1 INFO ? odoo: addons paths: ['/usr/lib/python3/dist-packages/odoo/addons', '/var/lib/odoo/addons/17.0', '/mnt/extra-addons']
2023-12-13 15:10:40,680 1 INFO ? odoo: database: odoo@db:5432
2023-12-13 15:10:40,872 1 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
Traceback (most recent call last):
  File "/usr/bin/odoo", line 8, in <module>
    odoo.cli.main()
  File "/usr/lib/python3/dist-packages/odoo/cli/command.py", line 66, in main
    o.run(args)
  File "/usr/lib/python3/dist-packages/odoo/cli/server.py", line 179, in run
    main(args)
  File "/usr/lib/python3/dist-packages/odoo/cli/server.py", line 172, in main
    rc = odoo.service.server.start(preload=preload, stop=stop)
  File "/usr/lib/python3/dist-packages/odoo/service/server.py", line 1402, in start
    rc = server.run(preload, stop)
  File "/usr/lib/python3/dist-packages/odoo/service/server.py", line 577, in run
    self.start(stop=stop)
  File "/usr/lib/python3/dist-packages/odoo/service/server.py", line 531, in start
    self.http_spawn()
  File "/usr/lib/python3/dist-packages/odoo/service/server.py", line 511, in http_spawn
    t.start()
  File "/usr/lib/python3.10/threading.py", line 935, in start
    _start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread

docker-compose.yml:

version: '3.1'
services:
  web:
    image: odoo:17.0
    depends_on:
      - db
    ports:
      - "8069:8069"
      - "8072:8072"
    environment:
      - HOST=db
      - USER=odoo
      - PASSWORD=myodoo
  db:
    image: postgres:13
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=odoo
      - POSTGRES_PASSWORD=myodoo
      - PGDATA=/var/lib/postgresql/data/pgdata

amh-mw commented

I just ran docker-compose up with your yaml and it worked fine for me.

2023-12-13 15:44:39,717 1 INFO ? odoo: Odoo version 17.0-20231208 
2023-12-13 15:44:39,717 1 INFO ? odoo: Using configuration file at /etc/odoo/odoo.conf 
2023-12-13 15:44:39,717 1 INFO ? odoo: addons paths: ['/usr/lib/python3/dist-packages/odoo/addons', '/var/lib/odoo/addons/17.0', '/mnt/extra-addons'] 
2023-12-13 15:44:39,717 1 INFO ? odoo: database: odoo@db:5432 
2023-12-13 15:44:40,020 1 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf 
2023-12-13 15:44:40,291 1 INFO ? odoo.service.server: HTTP service (werkzeug) running on 179d8fd85987:8069 

Maybe insufficient resources allocated to Docker? I'm running Docker Desktop on Mac with resource allocation set to 8 vCPU, 20 GB memory and 2 GB swap.

I am experiencing the same issue.

The problem could be solved by updating the docker version.

@khirschmann-huebinet Can you close this issue if you have a resolution?

Resolving Odoo 17 Thread Error in Docker
I encountered a RuntimeError: can't start new thread error while running Odoo 17 in a Docker container. After some troubleshooting, I found that the container needed additional privileges to access host machine resources. Here’s how I resolved the issue:

Use the --privileged Flag: Running the Docker container with the --privileged flag allows the container to access host resources directly, which can help resolve threading issues. You can modify your docker-compose.yml to include this flag :

services:
  web:
    ...
    privileged: true

It will work me
Note :

  1. Use the --privileged flag only when absolutely necessary.
  2. Consider using more granular capabilities with the --cap-add and --cap-drop options to limit the privileges instead of enabling all.
  3. Regularly review and audit containers running with elevated privileges.