title: Docker & Selenium unable to connect to renderer
body: <p>I am trying to setup browser testing with selenium and docker with behat.</p>
  
  <p>The main issue I am having is reliability when running the tests.</p>
  
  <p>Sometimes I can get connected and am able to run tests fine, but a lot of the time I cannot.</p>
  
  <p>It seems quite inconsistent, I startup the containers and run tests, first time fails, run again, the second time it runs and works fine.</p>
  
  <p>Once I restart the selenium-hub and run tests again it's fine (mostly).</p>
  
  <p>Thanks for the help.</p>
  
  <p>A common error I get is:</p>
  
  <pre><code>  Could not open connection: session not created exception
    from disconnected: unable to connect to renderer
      (Session info: chrome=61.0.3163.91)
      (Driver info: chromedriver=2.32.498513 (2c63aa53b2c658de596ed550eb5267ec5967b351),platform=Linux 4.4.0-96-generic x86_64) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 411 milliseconds
    Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
    System info: host: 'e0218fe24a14', ip: '172.18.0.6', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-96-generic', java.version: '1.8.0_131'
    Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException)
  </code></pre>
  
  <p>docker-compose.yml</p>
  
  <pre><code>version: '2'
  services:
      db:
          build:
              context: .
              dockerfile: DockerfileDb
          container_name: db
          ports:
              - "3396:3306"
          environment:
              - MYSQL_ROOT_PASSWORD=password
  
      web:
          build:
              context: .
              dockerfile: DockerfileWeb
          depends_on:
              - db
          container_name: web
          ports:
              - "8080:80"
          links:
              - db
              - selenium-hub
          environment: 
              - LOCALHOST_DOCKER=db
              - MYSQL_USER=root
              - MYSQL_PASSWORD=password
          volumes:
              - ./conf/rsyslog.conf:/etc/rsyslog.d/rsyslog-custom.conf        
              - ./:/var/www
              - ./sites-enabled:/etc/apache2/sites-enabled
              - ./conf/hosts:/etc/hosts
  
      selenium-hub:
          container_name: selenium_hub
          image: selenium/hub
          ports:
              - "4444:4444"
  
      chrome:
          container_name: selenium_node_chrome
          image: selenium/node-chrome
          volumes:
              - /dev/shm:/dev/shm # Mitigates the Chromium issue described at https://code.google.com/p/chromium/issues/detail?id=519952
          links:
              - selenium-hub
              - web
          environment:
              - HUB_PORT_4444_TCP_ADDR=selenium-hub
              - HUB_PORT_4444_TCP_PORT=4444
          volumes:
              - ./conf/hosts_selenium:/etc/hosts
          depends_on:
              - selenium-hub
          shm_size: 1g
  
      firefox:
          container_name: selenium_node_firefox
          image: selenium/node-firefox
          links:
              - selenium-hub
              - web
          environment:
              - HUB_PORT_4444_TCP_ADDR=selenium-hub
              - HUB_PORT_4444_TCP_PORT=4444
          volumes:
              - ./conf/hosts_selenium:/etc/hosts
          depends_on:
              - selenium-hub
  </code></pre>
  
  <p>behat.yml</p>
  
  <pre><code>default:
      extensions:
          Laracasts\Behat:
              # env_path: .env.behat
          Behat\MinkExtension:
              base_url: http://**********:8080/
              default_session: laravel
              laravel: ~
              selenium2:
                  wd_host: http://selenium_node_chrome:5555/wd/hub
                  capabilities: {'platform': 'LINUX', 'browser': 'chrome'}
              browser_name: chrome
  </code></pre>
  
  <p>login.feature</p>
  
  <pre><code>@mink:selenium2
  Feature: login
      Users should be able to login
  
    Scenario: Login Successfully                   # features/Login.feature:5
      When I wait 1 seconds                        # FeatureContext::iWaitSeconds()
        Could not open connection: session not created exception
        from disconnected: unable to connect to renderer
          (Session info: chrome=61.0.3163.91)
          (Driver info: chromedriver=2.32.498513 (2c63aa53b2c658de596ed550eb5267ec5967b351),platform=Linux 4.4.0-96-generic x86_64) (WARNING: The server did not provide any stacktrace information)
        Command duration or timeout: 411 milliseconds
        Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
        System info: host: 'e0218fe24a14', ip: '172.18.0.6', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-96-generic', java.version: '1.8.0_131'
        Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException)
      Given I am on "/"                            # FeatureContext::visit()
      Then print current URL                       # FeatureContext::printCurrentUrl()
      Then take screenshot "test1.png"             # FeatureContext::takeScreenshot()
      Then I should not see "Whoops"               # FeatureContext::assertPageNotContainsText()
      And I should not see "ERR_NAME_NOT_RESOLVED" # FeatureContext::assertPageNotContainsText()
      Then take screenshot "login_test.png"   
  </code></pre>