title: Using selenium/standalone-chrome in docker-compose connecting with Python's selenium
body: <p>I've been having trouble getting Python selenium to connect to <code>selenium/standalone-chrome</code>, and was looking for insight on how to fix my issue. I would like to avoid using <code>selenium/hub</code>, but including it does not seem to fix my issue.</p>
  
  <p>Here is my docker-compose.yml</p>
  
  <pre><code>version: '3.1'
  
  networks:
    web:
      external: true
  
  services:
  
    chrome:
      image: selenium/standalone-chrome:latest
      hostname: chrome
      networks:
        - web
      ports:
        - "5900:5900"
        - "4444:4444"
      privileged: true
      shm_size: 2g
  
    tests:
      build: ./tests
      networks:
        - web
  </code></pre>
  
  <p>And the test I'm running inside the test container. The entrypoint checks to make sure that chrome is up and running before running the scripts.</p>
  
  <pre><code>#!/usr/bin/env python3
  """Tests that the remote webdriver works."""
  import unittest
  from selenium import webdriver
  from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  
  
  class LocalGoogleTestCase(unittest.TestCase):
  
      def setUp(self):
          self.browser = webdriver.Chrome()
          self.addCleanup(self.browser.quit)
  
      def testPageTitle(self):
          self.browser.get('http://www.google.com')
          self.assertIn('Google', self.browser.title)
  
  
  class RemoteGoogleTestCase(unittest.TestCase):
  
      def setUp(self):
          self.browser = webdriver.Remote(
              command_executor='http://chrome:4444/wd/hub',
              desired_capabilities=DesiredCapabilities.CHROME)
          self.addCleanup(self.browser.quit)
  
      def testPageTitle(self):
          self.browser.get('http://www.google.com')
          self.assertIn('Google', self.browser.title)
  
  
  if __name__ == '__main__':
      unittest.main(verbosity=2)
  
  </code></pre>
  
  <p>For the test results, the <code>Local</code> test succeeds, it's only when trying to use the remote. Occasionally I will get the error <code>hub not found in PATH</code>, but that error is intermittent.</p>
  
  <p>I am able to access the web interface via <code>http://server:444/wd/hub</code> and can start sessions and run scripts from there.</p>
  
  <p>I believe this may be an issue related to containers not being able to reach out to each other and I have evaluated the following resources for trying to workout that issue:</p>
  
  <ul>
  <li><a href="https://forums.docker.com/t/cant-connect-to-other-containers-inside-docker-network/66512" rel="noreferrer">https://forums.docker.com/t/cant-connect-to-other-containers-inside-docker-network/66512</a></li>
  <li><a href="https://forums.docker.com/t/docker-compose-doesnt-let-my-images-connect-with-each-other/54951" rel="noreferrer">https://forums.docker.com/t/docker-compose-doesnt-let-my-images-connect-with-each-other/54951</a></li>
  </ul>
  
  <p>Posts I've examined which did not work:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/29781266/docker-using-container-with-headless-selenium-chromedriver">Docker: using container with headless Selenium Chromedriver</a></li>
  <li><a href="https://stackoverflow.com/questions/52004832/docker-selenium-standalone-chrome-unable-to-connect-to-docker-web-server">docker selenium/standalone-chrome unable to connect to docker web server</a></li>
  <li><a href="https://stackoverflow.com/questions/45014781/easiest-way-to-run-selenium-tests-in-a-docker-container-over-jenkins-ci">Easiest way to run Selenium tests in a Docker container over Jenkins CI</a></li>
  <li><a href="https://stackoverflow.com/questions/59159994/selenium-webdriver-remote-driver-does-not-work-with-tor-proxywebdriver-chrome-d">Selenium webdriver.Remote driver does not work with tor proxy(webdriver.Chrome does)</a></li>
  <li><a href="https://stackoverflow.com/questions/37685543/how-do-i-link-and-scale-multiple-docker-containers">How do I link and scale multiple docker containers?</a></li>
  <li><a href="https://stackoverflow.com/questions/48527048/how-to-point-remotewebdriver-to-one-of-the-multiple-standalone-docker-selenium-s">How to point RemoteWebDriver to one of the multiple standalone docker selenium standalone chrome browsers?</a></li>
  </ul>
  
  <p>Thanks for looking!</p>
  
  <p>Update: From within the tests container, I am able to <code>curl http://chrome:4444/wd/hub/status</code> to retrieve the status that the connection is up and running, and this is part of the <code>entryscript.sh</code>, so I know the containers can talk to each other in some fashion.</p>