Docker-selenium: chrome not reachable with docker and intranet site

Created on 3 Nov 2015  路  3Comments  路  Source: SeleniumHQ/docker-selenium

I'm trying out the standard nodechrome and nodefirefox images with docker-compose tied into the hub image also found in this repo.

When I try to visit two internal intranet sites in this format, the second request fails with the Chrome driver but works every time with the firefox driver.

new driver... capabilities = chrome
get Intranet Url 1
quit driver

new driver... capabilities = chrome
get Intranet Url 2
quit driver

Client code is .NET running on Windows 7 with latest Selenium nuget packages.

<packages>
  <package id="Selenium.Support" version="2.48.0" targetFramework="net45" />
  <package id="Selenium.WebDriver" version="2.48.0" targetFramework="net45" />
</packages>

This doesn't happen when running outside of the docker container, the scripts do contain the no sandbox flag and the images I'm running are up to date (pulled from docker registry)

Grid:

hub:
  image: selenium/hub
  ports:
    - "4444:4444"
firefox1:
  image: selenium/node-firefox
  links:
    - hub
chrome1:
  image: selenium/node-chrome
  links:
    - hub

NB I have also tried privileged: true with chrome.

Full error trace with URLs removed for privacy.

hub_1      | 11:22:33.593 INFO - Got a request to create a new session: Capabilities [{browserName=chrome, javascriptEnabled=true, version=, platform=LINUX}]
hub_1      | 11:22:33.593 INFO - Available nodes: [http://172.17.0.94:5555, http://172.17.0.93:5555]
hub_1      | 11:22:33.593 INFO - Trying to create a new session on node http://172.17.0.94:5555
hub_1      | 11:22:33.594 INFO - Node http://172.17.0.94:5555 has no matching capability
hub_1      | 11:22:33.594 INFO - Trying to create a new session on node http://172.17.0.93:5555
hub_1      | 11:22:33.594 INFO - Trying to create a new session on test slot {seleniumProtocol=WebDriver, browserName=chrome, maxInstances=1, platform=LINUX}
chrome1_1  | 03:22:33.598 INFO - Executing: [new session: Capabilities [{browserName=chrome, javascriptEnabled=true, version=, platform=LINUX}]])
chrome1_1  | 03:22:33.602 INFO - Creating a new session for Capabilities [{browserName=chrome, javascriptEnabled=true, version=, platform=LINUX}]
chrome1_1  | Starting ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b) on port 26346
chrome1_1  | Only local connections are allowed.
chrome1_1  | 03:22:34.375 INFO - Done: [new session: Capabilities [{browserName=chrome, javascriptEnabled=true, version=, platform=LINUX}]]
chrome1_1  | 03:22:34.611 INFO - Executing: [get: https://intranetURL1])
chrome1_1  | 03:22:46.079 INFO - Done: [get: https://intranetURL1]
chrome1_1  | 03:22:47.791 INFO - Executing: [take screenshot])
chrome1_1  | 03:22:48.426 INFO - Done: [take screenshot]
chrome1_1  | 03:22:48.977 INFO - Executing: [get: IntranetUrl2])
chrome1_1  | [16.191][SEVERE]: Unable to receive message from renderer
chrome1_1  | 03:22:49.805 INFO - Done: [get: IntranetUrl2]
chrome1_1  | 03:22:51.517 INFO - Executing: [take screenshot])
chrome1_1  | 03:22:51.521 WARN - Exception thrown
chrome1_1  | org.openqa.selenium.WebDriverException: chrome not reachable
chrome1_1  |   (Session info: chrome=46.0.2490.71)
chrome1_1  |   (Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b),platform=Linux 4.2.0-16-generic x86_64) (WARNING: The server did not provide any stacktrace information)
chrome1_1  | Command duration or timeout: 3 milliseconds
chrome1_1  | Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
chrome1_1  | System info: host: 'b7aab1623135', ip: '172.17.0.93', os.name: 'Linux', os.arch: 'amd64', os.version: '4.2.0-16-generic', java.version: '1.8.0_45-internal'
chrome1_1  | Driver info: org.openqa.selenium.chrome.ChromeDriver
chrome1_1  | Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/tmp/.com.google.Chrome.ExtH8P}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=46.0.2490.71, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
chrome1_1  | Session ID: 5ba7e3467ece6b29a7bcaae6b991a510
chrome1_1  |    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
chrome1_1  |    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
chrome1_1  |    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
chrome1_1  |    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
chrome1_1  |    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
chrome1_1  |    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
chrome1_1  |    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
chrome1_1  |    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:670)
chrome1_1  |    at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:325)
chrome1_1  |    at org.openqa.selenium.remote.server.handler.CaptureScreenshot.call(CaptureScreenshot.java:36)
chrome1_1  |    at org.openqa.selenium.remote.server.handler.CaptureScreenshot.call(CaptureScreenshot.java:1)
chrome1_1  |    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
chrome1_1  |    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
chrome1_1  |    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
chrome1_1  |    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
chrome1_1  |    at java.lang.Thread.run(Thread.java:745)
chrome1_1  | 03:22:51.522 WARN - Exception: chrome not reachable
chrome1_1  |   (Session info: chrome=46.0.2490.71)
chrome1_1  |   (Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b),platform=Linux 4.2.0-16-generic x86_64) (WARNING: The server did not provide any stacktrace information)
chrome1_1  | Command duration or timeout: 3 milliseconds
chrome1_1  | Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
chrome1_1  | System info: host: 'b7aab1623135', ip: '172.17.0.93', os.name: 'Linux', os.arch: 'amd64', os.version: '4.2.0-16-generic', java.version: '1.8.0_45-internal'
chrome1_1  | Driver info: org.openqa.selenium.chrome.ChromeDriver
chrome1_1  | Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/tmp/.com.google.Chrome.ExtH8P}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=46.0.2490.71, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
chrome1_1  | Session ID: 5ba7e3467ece6b29a7bcaae6b991a510
chrome1_1  | 03:22:51.578 INFO - Executing: [delete session: 9f8c0724-264c-4973-9852-381b44a68fd5])
chrome1_1  | 03:22:52.085 INFO - Done: [delete session: 9f8c0724-264c-4973-9852-381b44a68fd5]


Most helpful comment

One of the most frequent issues with chrome in docker container is small size od /dev/shm . It's easy to check with launching chrome container with /dev/shm mounted from the host. Simply add to docker-compose.yml:
volumes:

  • /dev/shm:/dev/shm

If the problem's gone, you are to increase shm size (there is a number of ways).
It's not good to mount host's shm due to security aspect, but for testing purposes it's the simpliest way

All 3 comments

One of the most frequent issues with chrome in docker container is small size od /dev/shm . It's easy to check with launching chrome container with /dev/shm mounted from the host. Simply add to docker-compose.yml:
volumes:

  • /dev/shm:/dev/shm

If the problem's gone, you are to increase shm size (there is a number of ways).
It's not good to mount host's shm due to security aspect, but for testing purposes it's the simpliest way

@apakhomov thanks for this, it did work very well. Do you have a link for increasing /dev/shm for the container?

@alexellis

I use this way (I know, "privileged" is not good, but it's testing environment, so security is not so important). Hope, this helps:

cat docker-compose.yml

nodechrome:
image: selenium/node-chrome
volumes:
- ./resources:/usr/lib/selenium/resources:ro
- ./config.json:/opt/selenium/config.json:ro
- ./pre_entry_point.sh:/opt/bin/pre_entry_point.sh
privileged: true
command:
- /opt/bin/pre_entry_point.sh
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-grid
- HUB_PORT_4444_TCP_PORT=4444

cat pre_entry_point.sh

!/bin/bash

echo -e "Re-mounting shm and tmp\n\n"
sudo umount -l /dev/shm
sudo umount -l /tmp
sudo mount -t tmpfs -o size=1024m tmpfs /dev/shm #use your values there
sudo mount -t tmpfs -o size=512m tmpfs /tmp
echo -e "\n\n"
cat /proc/mounts
echo -e "\n\n"
df -h
echo -e "\n\nStarting node\n\n"

. /opt/bin/entry_point.sh

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pfluegs picture pfluegs  路  4Comments

Bernardoow picture Bernardoow  路  4Comments

testphreak picture testphreak  路  6Comments

minhnguyenvan95 picture minhnguyenvan95  路  5Comments

JordiGiros picture JordiGiros  路  4Comments