Skip to content
Advertisement

How to connect to remote Selenium drivers within the same docker-compose?

I ran into a

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=’chromedriver’, port=4444): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0x7fc2de559bb0>: Failed to establish a new connection: [Errno 111] Connection refused’))

While running Selenium via Python and Docker.

My Connection looks like this:

self.driver = webdriver.Remote(
           command_executor='http://chromedriver:4444/wd/hub',
           options=options
       )

The docker-compose like this:

...
  chromedriver:
    image: selenium/standalone-chrome
    ports:
      - "4444:4444"
    hostname: chromedriver
    shm_size: 2g
  runner:
    image: "kevoooo/twitchfarm-runner:latest"
    entrypoint: "python3 /py-scripts/main.py"
    healthcheck:
        test: python3 /py-scripts/main.py
        interval: 30s
        timeout: 10s
        retries: 5
    environment:
      - DISPLAY=127.0.0.1
      - USER=uname
      - PASS=pass
      - 2FA_KEY=key
    volumes:
      - "chrome-data:/saves/google-chrome"
    depends_on:
      - chromedriver
...

Thanks in advance!

Advertisement

Answer

I solved it by changing the entrypoint of “runner” to:

    entrypoint: bash -c "sleep 10 && python3 /py-scripts/main.py"

I thought, that was handled by the “depends-on”-clause

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement