Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to spawn browser inside my Docker container app #2140

Open
MutarIO opened this issue Feb 14, 2025 · 1 comment
Open

Fails to spawn browser inside my Docker container app #2140

MutarIO opened this issue Feb 14, 2025 · 1 comment

Comments

@MutarIO
Copy link

MutarIO commented Feb 14, 2025

Hello guys,

I have a Docker container app in which I am trying to utilize nodriver in a python script.
However, for some reason it will never start properly.

When I try to spawn a browser (using the no_sandbox=True parameter inside my start function) I get the following error:

`(venv) root@cdee75c0f2bd:/var/www/python# python scraper/nodriver_scraper.py "https://example.com" "body"
Error:
---------------------
Failed to connect to browser
---------------------
One of the causes could be when you are running as root.
In that case you need to pass no_sandbox=True

Traceback: Traceback (most recent call last):
File "/var/www/python/scraper/nodriver_scraper.py", line 12, in scrape
driver = await uc.start(sandbox=False, headless=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/www/python/venv/lib/python3.11/site-packages/nodriver/core/util.py", line 95, in start
return await Browser.create(config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/www/python/venv/lib/python3.11/site-packages/nodriver/core/browser.py", line 90, in create
await instance.start()
File "/var/www/python/venv/lib/python3.11/site-packages/nodriver/core/browser.py", line 351, in start
raise Exception(
Exception:
---------------------
Failed to connect to browser
---------------------
One of the causes could be when you are running as root.
In that case you need to pass no_sandbox=True

{"status": "error", "error": "\n ---------------------\n Failed to connect to browser\n ---------------------\n One of the causes could be when you are running as root.\n In that case you need to pass no_sandbox=True \n ", "traceback": "Traceback (most recent call last):\n File "/var/www/python/scraper/nodriver_scraper.py", line 12, in scrape\n driver = await uc.start(sandbox=False, headless=False)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/var/www/python/venv/lib/python3.11/site-packages/nodriver/core/util.py", line 95, in start\n return await Browser.create(config)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/var/www/python/venv/lib/python3.11/site-packages/nodriver/core/browser.py", line 90, in create\n await instance.start()\n File "/var/www/python/venv/lib/python3.11/site-packages/nodriver/core/browser.py", line 351, in start\n raise Exception(\nException: \n ---------------------\n Failed to connect to browser\n ---------------------\n One of the causes could be when you are running as root.\n In that case you need to pass no_sandbox=True \n \n"}`

I am already running with no_sandbox=True but this does not help.

If anyone knows a fix, please let me know!

@MutarIO
Copy link
Author

MutarIO commented Feb 14, 2025

I got everything working with Symfony Panther which also uses the same binary so the installation of Chromium inside my container is not the issue here. I am using the PHP-FPM base image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant