-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fails to spawn browser inside my Docker container app #2140
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
Comments
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. |
Same issue here .. |
Since when are Docker containers designed to run Gui apps? Without hacks you can't easily just start a browser |
Headless browser for dynamic webscraping is widely used. You need to install some dependencies but you can do it perfectly fine, headless or not. |
Any update about this issue please ? It was working fine before but starting from last week the start() method started throwing this error :
I've tried setting sanbox to false, changing user to non-root user, using new user_data_dir, --disable-dev-shm-usage and plenty of other workarounds, but none of them is working. IS this related to Nodriver or the browser itself ?? |
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!
The text was updated successfully, but these errors were encountered: