joyzoursky / docker-python-chromedriver

Dockerfile for running Python Selenium in headless Chrome (Python 2.7 / 3.6 / 3.7 / 3.8 / Alpine based Python / Chromedriver / Selenium / Xvfb included in different versions)

Home Page:https://hub.docker.com/r/joyzoursky/python-chromedriver/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chrome failed to start: crashed. (chrome not reachable)

jhnyc opened this issue · comments

I've tested both images 3.8-selenium and 3.9-selenium using the configurations in the test_script.py:

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument("--window-size=1920,1080")
driver = webdriver.Chrome(options=chrome_options)

Both throw this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 76, in __init__
    RemoteWebDriver.__init__(
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed.
  (chrome not reachable)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

In my case, I was using an M1 Mac.
I used the arm-only docker and it worked fine. selenium/standalone-chrome

Running into this issue as well with an M1 Mac.

When I try to use selenium/standalone-chrome I get Message: 'chromedriver' executable needs to be in PATH.

@jhnyc @AsheKR have you able to solve it?
I'm trying to run chromium-browser inside linux/amd64 built docker container on my m1 mac, having this:

/ # chromium-browser --no-sandbox --headless --disable-dev-shm-usage --disable-gpu --window-size=1920,1080 "https://example.com/"
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[1123/102811.182268:ERROR:bus.cc(398)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[1123/102811.186957:ERROR:bus.cc(398)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[1123/102811.217043:WARNING:dns_config_service_linux.cc(428)] Failed to read DnsConfig.
qemu: unknown option 'type=utility'
[1123/102811.399626:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
[1123/102811.402807:ERROR:gpu_process_host.cc(967)] GPU process launch failed: error_code=1002
[1123/102811.403232:WARNING:gpu_process_host.cc(1273)] The GPU process has crashed 1 time(s)
[1123/102811.474123:ERROR:network_service_instance_impl.cc(470)] Network service crashed, restarting service.
qemu: unknown option 'type=utility'
[1123/102811.700157:ERROR:gpu_process_host.cc(967)] GPU process launch failed: error_code=1002
[1123/102811.700235:WARNING:gpu_process_host.cc(1273)] The GPU process has crashed 2 time(s)
[1123/102811.720520:ERROR:network_service_instance_impl.cc(470)] Network service crashed, restarting service.
qemu: unknown option 'type=utility'
[1123/102811.985840:ERROR:gpu_process_host.cc(967)] GPU process launch failed: error_code=1002
[1123/102811.985931:WARNING:gpu_process_host.cc(1273)] The GPU process has crashed 3 time(s)
[1123/102812.016132:ERROR:network_service_instance_impl.cc(470)] Network service crashed, restarting service.
[1123/102812.024892:ERROR:gpu_process_host.cc(967)] GPU process launch failed: error_code=1002
[1123/102812.024971:WARNING:gpu_process_host.cc(1273)] The GPU process has crashed 4 time(s)
qemu: unknown option 'type=utility'
[1123/102812.054398:ERROR:gpu_process_host.cc(967)] GPU process launch failed: error_code=1002
[1123/102812.054503:WARNING:gpu_process_host.cc(1273)] The GPU process has crashed 5 time(s)
[1123/102812.055918:ERROR:network_service_instance_impl.cc(470)] Network service crashed, restarting service.
qemu: unknown option 'type=utility'
[1123/102812.084531:ERROR:gpu_process_host.cc(967)] GPU process launch failed: error_code=1002
[1123/102812.084893:WARNING:gpu_process_host.cc(1273)] The GPU process has crashed 6 time(s)
[1123/102812.084977:FATAL:gpu_data_manager_impl_private.cc(450)] GPU process isn't usable. Goodbye.
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
Trace/breakpoint trap

I found another function, this same as selenium.
and can running on Apple Silicon and Docker.
https://github.com/microsoft/playwright-python

Has anyone figured out the fix yet? I can reproduce this on Apple Silicon M1 based Docker. Works fine on Intel based macOS.