Skip to content

Headless chrome is not working in the docker #520

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

Closed
kootenpv opened this issue Jul 16, 2017 · 30 comments
Closed

Headless chrome is not working in the docker #520

kootenpv opened this issue Jul 16, 2017 · 30 comments

Comments

@kootenpv
Copy link

kootenpv commented Jul 16, 2017

Image:

$ docker images
REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE
selenium/standalone-chrome                      latest              1dec27211cb6        2 weeks ago         835MB

Container:

853711d44c1e        selenium/standalone-chrome   "/opt/bin/entry_po..."   18 minutes ago      Up 18 
minutes              0.0.0.0:4444->4444/tcp   hopeful_shannon
# This does NOT work
URL = 'http://localhost:4444/wd/hub'
options = webdriver.ChromeOptions()
options.add_argument('headless')
# for remote, options need to be converted to capabilities
driver = webdriver.Remote(command_executor=URL,
                          desired_capabilities=options.to_capabilities())

# this works (but is not using docker)
webdriver.Chrome(options=options)

Stack trace of not working (it times out):

---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
<ipython-input-62-f265e82ae069> in <module>()
      4 # for remote, options need to be converted to capabilities
      5 driver = webdriver.Remote(command_executor=URL,
----> 6                           desired_capabilities=options.to_capabilities())

/home/pascal/python/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector)
     96             warnings.warn("Please use FirefoxOptions to set browser profile",
     97                           DeprecationWarning)
---> 98         self.start_session(desired_capabilities, browser_profile)
     99         self._switch_to = SwitchTo(self)
    100         self._mobile = Mobile(self)

/home/pascal/python/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py in start_session(self, capabilities, browser_profile)
    186         parameters = {"capabilities": w3c_caps,
    187                       "desiredCapabilities": capabilities}
--> 188         response = self.execute(Command.NEW_SESSION, parameters)
    189         if 'sessionId' not in response:
    190             response = response['value']

/home/pascal/python/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
    254         response = self.command_executor.execute(driver_command, params)
    255         if response:
--> 256             self.error_handler.check_response(response)
    257             response['value'] = self._unwrap_value(
    258                 response.get('value', None))

/home/pascal/python/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
    192         elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
    193             raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
--> 194         raise exception_class(message, screen, stacktrace)
    195 
    196     def _value_or_default(self, obj, key, default):

WebDriverException: Message: unknown error: Chrome failed to start: exited normally
  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.11.9-1-ARCH x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.05 seconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'c3e9aafe9593', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.11.9-1-ARCH', java.version: '1.8.0_131'
Driver info: driver.version: ChromeDriver
Stacktrace:
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable (ErrorHandler.java:215)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed (ErrorHandler.java:167)
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0 (JsonWireProtocolResponse.java:53)
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2 (JsonWireProtocolResponse.java:91)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$22 (ProtocolHandshake.java:365)
    at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:193)
    at java.util.Spliterators$ArraySpliterator.tryAdvance (Spliterators.java:958)
    at java.util.stream.ReferencePipeline.forEachWithCancel (ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel (AbstractPipeline.java:498)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:485)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:471)
    at java.util.stream.FindOps$FindOp.evaluateSequential (FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst (ReferencePipeline.java:464)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession (ProtocolHandshake.java:368)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession (ProtocolHandshake.java:159)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute (HttpCommandExecutor.java:142)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute (DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:637)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession (RemoteWebDriver.java:250)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession (RemoteWebDriver.java:236)
    at org.openqa.selenium.remote.RemoteWebDriver.<init> (RemoteWebDriver.java:137)
    at org.openqa.selenium.chrome.ChromeDriver.<init> (ChromeDriver.java:184)
    at org.openqa.selenium.chrome.ChromeDriver.<init> (ChromeDriver.java:148)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:423)
    at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor (DefaultDriverProvider.java:102)
    at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance (DefaultDriverProvider.java:96)
    at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance (DefaultDriverFactory.java:60)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:222)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:209)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at org.openqa.selenium.remote.server.DefaultSession$1.run (DefaultSession.java:176)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
    at java.lang.Thread.run (Thread.java:748)
@kootenpv
Copy link
Author

Another attempt:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

options = webdriver.ChromeOptions()
URL = 'http://localhost:4444/wd/hub'
options.add_argument('--headless')
options.add_argument("--no-sandbox")
options.add_argument("--disable-gpu")
options.add_argument("--remote-debugin-port=9222")
options.add_argument("--screen-size=1200x800")

driver = webdriver.Remote(command_executor=URL,
                          desired_capabilities=options.to_capabilities())

@anyone-can-test
Copy link

anyone-can-test commented Jul 31, 2017

I have the same issue.
I use selenium/node-chrome:3.4.0-einsteinium.

// java
ChromeOptions chrome = new ChromeOptions();
    		chrome.addArguments("--headless");
    		chrome.addArguments("--disable-gpu");
 org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
      (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 3.10.0-327.36.3.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 60.03 seconds
    Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
    System info: host: '7b9eda8e6c5e', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.36.3.el7.x86_64', java.version: '1.8.0_131'
    Driver info: driver.version: ChromeDriver
    Command duration or timeout: 60.08 seconds
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

@gsureshbabu
Copy link

Yes, I observed similar issue in node chrome image. Driver initialization got failed.

@ajoy39
Copy link

ajoy39 commented Jul 31, 2017

Same here, can connect to the selenium service fine but Chrome fails to start.

---------
1) CreateMemberCept: 
 Test  tests/acceptance/Admin/CreateMemberCept.php
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  [Facebook\WebDriver\Exception\UnknownServerException] unknown error: Chrome failed to start: exited normally
  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.11.11-coreos x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.10 seconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: '05ad22650784', ip: '172.17.0.4', os.name: 'Linux', os.arch: 'amd64', os.version: '4.11.11-coreos', java.version: '1.8.0_131'
Driver info: driver.version: ChromeDriver  

@cbrevik
Copy link

cbrevik commented Aug 3, 2017

Experiencing the same error. Built a new Docker image based on 35b5040 and I get:

unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Linux 3.10.0-514.16.1.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)

Using RemoteWebDriver in C#.

Edit: Works fine with --headless and same C# code when running Chrome locally (not in Docker-container).

@cbrevik
Copy link

cbrevik commented Aug 3, 2017

Ran top on the node/container. It doesn't look like chromedriver-2 nor chrome is actually failing to start. Might be a communication error between the two when --headless is enabled?

Chrome goes idle really quickly in resource usage after starting though.

@rosskevin
Copy link

I am also unable to connect to selenium/standalone-chrome:3.5.2 with the following config:

prefs = {
  loggingPrefs: {
    browser: 'ALL'
  },
  chromeOptions: {
    prefs: {
      credentials_enable_service: false, # disable saved passwords
      profile: {
        password_manager_enabled: false  # disable saved passwords
      }
    },
    'args' => %w{headless no-sandbox disable-gpu} # https://github.com/dkastner/headless-chromium-selenium/blob/master/features/support/env.rb
  }
}

Selenium::WebDriver::Remote::Capabilities.chrome(prefs)

It simply gives me a Net::ReadTimeout. This works fine without the headless arg.

Am I mis-configuring headless mode?

@rosskevin
Copy link

Noted here:

If you use the headless_chrome driver on an older version of Chrome or on Windows, you will get a NetReadTimeout error.

But chrome docs say:

Caution: Headless mode is available on Mac and Linux in Chrome 59. Windows support is coming in Chrome 60. To check what version of Chrome you have, open chrome://version.

When I run selenium/standalone-chrome-debug:3.5.2 and vnc in, I see that the version of Chrome is 60.0.3112.113 (Official Build) (64-bit)

So it appears I have met all requirements and have a similar set of configurations as examples, yet still no response from the container.

@brandon-bethke-timu
Copy link

We are apparently having this same problem.
We are deploying chrome on minikube using the helm charts located here: https://github.com/kubernetes/charts/blob/master/stable/selenium/
We are using selenium docker image tag: 3.5.2-antimony

This setup is working as expected when NOT using the "headless" option. However, as soon as we add the "headless" arguments to the chrome options, we get this dreadful error:

    org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
  (Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Linux 4.9.13 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.05 seconds

        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.addArguments("headless");
        chromeOptions.addArguments("window-size=1200x600"); 
        chromeOptions.addArguments("disable-gpu");
        capabilities = DesiredCapabilities.chrome();
        capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
        ...
        ...
        driver = new RemoteWebDriver(hub, capabilities);

@viettd56
Copy link

viettd56 commented Sep 10, 2017

After few day search and try, finally I can run chrome headless mode by add option --privileged when run docker container :)

@kootenpv
Copy link
Author

@viettd56 Sounds great! Do you perhaps have a code snippet of the full example :)? I'm sure it would help others as well.

@viettd56
Copy link

viettd56 commented Sep 14, 2017

docker-compose.yml

selenium-hub:
  image: selenium/hub
  environment:
    - GRID_TIMEOUT=120
    - GRID_MAX_SESSION=200
    - GRID_NEW_SESSION_WAIT_TIMEOUT=-1
    - GRID_BROWSER_TIMEOUT=120
  ports:
    - "4444:4444"

chrome:
    image: selenium/node-chrome
    links:
      - selenium-hub:hub
    dns:
      - 8.8.8.8
      - 208.67.222.222
    environment:
      - NODE_MAX_INSTANCES=100
      - NODE_MAX_SESSION=100
    volumes:
      - /dev/shm:/dev/shm
    privileged: true

@kootenpv
Copy link
Author

kootenpv commented Sep 14, 2017

@viettd56 Thanks! As a result, I realized in the docker call I can add --privileged!

I ran:

 docker run --privileged -d -p 4444:4444 selenium/standalone-chrome

But now my code still just hangs, no clue why:

from selenium import webdriver

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

options = webdriver.ChromeOptions()
URL = 'http://localhost:4444/wd/hub'
options.add_argument('--headless')
options.add_argument("--no-sandbox")
options.add_argument("--disable-gpu")
options.add_argument("--remote-debugin-port=9222")
options.add_argument("--screen-size=1200x800")

driver = webdriver.Remote(command_executor=URL,
                          desired_capabilities=options.to_capabilities())

Did you use python or ??

@viettd56
Copy link

@kootenpv I seem that time I build custom docker container :D
Dockerfile

FROM ubuntu:14.04.5

USER root
RUN apt-get update --fix-missing
RUN apt-get install -y build-essential make g++ curl libfontconfig python curl wget unzip git
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
RUN apt-get install -y nodejs
# Install Chrome for Ubuntu
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - &&\
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' &&\
sudo apt-get update --fix-missing
RUN sudo apt-get install -y google-chrome-stable
# bla bla

and run this Dockerfile with option --privileged

@cbrevik
Copy link

cbrevik commented Sep 14, 2017

I've run the selenium/node-chrome-debug with priviliged and it still gets this error.

Maybe something you've done with that custom docker image which avoids this error? @viettd56

@viettd56
Copy link

@cbrevik https://github.com/viettd56/docker-chrome-headless-example
It is example dockerfile and docker-compose run nodejs with chrome headless. I install chrome in same image with code. Maybe image selenium node-chrome need change something

@maxlim0
Copy link

maxlim0 commented Sep 18, 2017

Experiencing the same error with --headless

@evertones
Copy link
Contributor

evertones commented Sep 21, 2017

I'm facing failures in Java/Scala as well when running using docker-selenium:3.5.3-astatine.

Scala code to create the headless driver:

val options = new ChromeOptions
options.addArguments("--headless")
options.addArguments("--disable-gpu")

val capability = DesiredCapabilities.chrome
capability.setBrowserName("chrome")
capability.setPlatform(org.openqa.selenium.Platform.ANY)
capability.setCapability(ChromeOptions.CAPABILITY, options)
// create the driver
new RemoteWebDriver("<url_to_be_tested>"), capability)

LOGs in Docker images (docker-compose logs):

hub_1      | 06:02:01.288 INFO - Mismatched capabilities. Creating a synthetic w3c capability.
hub_1      | 06:02:01.289 INFO - Got a request to create a new session: Capabilities [{browserName=chrome, chromeOptions={args=[--headless, --disable-gpu], extensions=[]}, platformName=ANY, version=, platform=ANY}]
hub_1      | 06:02:01.289 INFO - Trying to create a new session on test slot {seleniumProtocol=WebDriver, browserName=chrome, maxInstances=1, version=61.0.3163.79, applicationName=, platform=LINUX}
chrome_3   | 2017-09-21 06:02:01.298:INFO:osjshC.ROOT:qtp1979313356-17: org.openqa.selenium.remote.server.WebDriverServlet-6eda5c9: Initialising WebDriverServlet
chrome_3   | 06:02:01.351 INFO - Binding default provider to: org.openqa.selenium.chrome.ChromeDriverService
chrome_3   | 06:02:01.352 INFO - Found handler: org.openqa.selenium.remote.server.BeginSession@14ad7791
chrome_3   | 06:02:01.357 INFO - /session: Executing POST on /session (handler: BeginSession)
chrome_3   | 06:02:01.403 INFO - Mismatched capabilities. Creating a synthetic w3c capability.
chrome_3   | 06:02:01.408 INFO - Capabilities are: Capabilities {browserName=chrome, chromeOptions={args=[--headless, --disable-gpu], extensions=[], }, platformName=ANY, version=, platform=ANY, }
chrome_3   | 06:02:01.410 INFO - Capabilities {browserName=chrome, chromeOptions={args=[--headless, --disable-gpu], extensions=[], }, platformName=ANY, version=, platform=ANY, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
chrome_3   | 06:02:01.410 INFO - Capabilities {browserName=chrome, chromeOptions={args=[--headless, --disable-gpu], extensions=[], }, platformName=ANY, version=, platform=ANY, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
chrome_3   | 06:02:01.411 INFO - Capabilities {browserName=chrome, chromeOptions={args=[--headless, --disable-gpu], extensions=[], }, platformName=ANY, version=, platform=ANY, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
chrome_3   | Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 31450
chrome_3   | Only local connections are allowed.

LOGs in the console running the test:

*** RUN ABORTED *** (1 minute, 23 seconds)
  org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
  (Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Linux 4.4.0-78-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.06 seconds
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: '7fa67224bba8', ip: '172.18.0.4', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-78-generic', java.version: '1.8.0_131'
Driver info: driver.version: unknown
Command duration or timeout: 60.31 seconds
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
  at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
  at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
  at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
  at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:359)
  at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
  ...
  Cause: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
  (Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Linux 4.4.0-78-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.06 seconds
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: '7fa67224bba8', ip: '172.18.0.4', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-78-generic', java.version: '1.8.0_131'
Driver info: driver.version: unknown
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:42:44.417Z'
System info: host: 'everton-pc', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-93-generic', java.version: '1.8.0_111'
Driver info: driver.version: unknown
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
  at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
  at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
  at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
  at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:359)
  at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)

@Stevkar
Copy link

Stevkar commented Sep 21, 2017

Faced the same issue with Chrome v:61.0.3163.91 and ChromeDriver 2.32.498513 and Selenium 3.5.3.

@evertones
Copy link
Contributor

evertones commented Sep 22, 2017

I just started an image in debug-mode for version 3.5.3-boron and connected in it using VNC.
I opened a terminal and tried to run a few commands to start Chrome in headless mode:

seluser@cab6fc28ac66:/$ google-chrome --headless --disable-gpu 
[0922/020612.994035:ERROR:headless_shell.cc(132)] Navigation to  failed

seluser@cab6fc28ac66:/$ google-chrome --headless --disable-gpu --dump-dom https://www.google.com
[0922/020622.477093:ERROR:headless_shell.cc(505)] Open multiple tabs is only supported when remote debugging is enabled.

seluser@cab6fc28ac66:/$ google-chrome --headless --disable-gpu --dump-dom https://www.google.com --remote-debugging-port=9222
[0922/060450.343329:ERROR:headless_shell.cc(515)] Dump DOM is disabled when remote debugging is enabled.

Running google-chrome --headless --disable-gpu --dump-dom https://www.google.com/ in my workstation (ubuntu 16.04, Chrome 61.0.3163.91) prints all DOM for the given page.

@CowChris
Copy link

CowChris commented Sep 29, 2017

+1 Getting the "Message: unknown error: Chrome failed to start: exited normally" error as well...

Chriss-MacBook-Pro:connect chrisrosillo$ docker exec -it connect_selenium_1 chromedriver --version
ChromeDriver 2.32.498513 (2c63aa53b2c658de596ed550eb5267ec5967b351)
Chriss-MacBook-Pro:connect chrisrosillo$ docker exec -it connect_selenium_1 /opt/google/chrome/google-chrome --version
Google Chrome 61.0.3163.91 

Running via Codeception (tried every option/capability under the sun from various threads on this issue to no avail). My Codeceptionn config below (not working).

        - WebDriver:
            url: http://acceptance.tester
            browser: chrome
            host: selenium
            port: 4444
            window_size: false
            capabilities:
              useAutomationExtension: false
              chromeOptions:
                args: ["headless", "disable-gpu", "disable-infobars", "no-sandbox", "allow-insecure-localhost", "window-size=1200,800"]

Hope this gets fixed soon!

@CowChris
Copy link

chromedriver issue looks related: https://bugs.chromium.org/p/chromedriver/issues/detail?id=1972

@diemol
Copy link
Member

diemol commented Oct 17, 2017

I just tried the commands shown in this comment, with the current selenium/standalone-chrome-debug:3.6.0-bromine release, and they work.

One main difference with the previous version, is that the wrapper to launch Google Chrome was changed (it was pretty old). That could explain why all these options didn't work before.

Could you please try again and report back?

@evertones
Copy link
Contributor

evertones commented Oct 17, 2017

@diemol: I've updated my images with selenium/standalone-chrome-debug:3.6.0-bromine and ran again the commands.
They worked fine.

Here's the result:

seluser@b9e5ef2a74bd:/$ google-chrome --headless --disable-gpu
seluser@b9e5ef2a74bd:/$ google-chrome --headless --disable-gpu --dump-dom http://www.google.com
<body class="hp vasq" onload="document.f&amp;&amp;document.f.q.focus();
...

Thank you very much!

@diemol
Copy link
Member

diemol commented Oct 18, 2017

Great! Closing the issue then.

@diemol diemol closed this as completed Oct 18, 2017
@laurahannah
Copy link

Are there any pointers on how to use the chrome-debug image in a docker-compose file?

@laurahannah
Copy link

laurahannah commented Apr 16, 2018

We need to use a docker-compose file because we are using a gradle plugin to do the compose up. With this plugin (avast) you cannot specify the ports. FWIW, changing the image to selenium/standalone-chrome-debug in the docker-compose file fails spectacularly. the debug chrome containers cannot attach to the hub.

@loblab
Copy link

loblab commented Apr 25, 2018

run into same issue in my self build docker (debian 9 based), adding "no-sandbox" works. "privileged" or "disable-gpu" is not necessary.

run as normal user (not root).

        options = webdriver.ChromeOptions()
        options.add_argument("headless")
        #options.add_argument("privileged")
        options.add_argument("no-sandbox")
        #options.add_argument("disable-gpu")
        options.add_argument("window-size=1200x800")
        self.browser = webdriver.Chrome(chrome_options=options)

@Lafaiet
Copy link

Lafaiet commented May 11, 2018

@loblab I've been struggling with this issue for days. I cant believe a single "no-sandbox" solved the issue! Anyways. Thanks a bunch!!!!

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

No branches or pull requests