[Python] Unable to discover proper chromedriver version in offline mode in Docker Web App...

Discussão em 'Python' iniciado por Stack, Julho 18, 2025.

  1. Stack

    Stack Membro Participativo

    I'm running a web app on Azure from a Docker container based on a Selenium image (selenium/standalone-chrome:latest). It ran perfectly fine, but out of nowhere (after changing something unrelated in the data handling section separate from my scraper) started giving me the following error: "Unable to discover proper chromedriver version in offline mode".

    The weird thing is that my API is still running fine online; I can get and post requests and from my logs I can see they're received and handled properly up until the chromedriver is initiated (which fails).

    The error occurs here during the instantiation of the driver:

    # import chromedriver_binary
    from selenium.webdriver import Chrome, ChromeOptions

    def _GetDriver() -> Chrome:
    options = ChromeOptions()
    options.add_argument("--headless")
    options.add_argument('--disable-gpu')
    options.add_argument('--no-sandbox')

    return Chrome(options=options) # <--- Error happens here.

    def _EnrichAtomicAddress(info: dict) -> dict:
    with _GetDriver() as driver: # <--- Only place _GetDriver is called.
    data = XXXXXX(driver, info)
    data['lastScrapedDate'] = date.today()
    data['retrievalDate'] = date.today()

    if 'errorMessage' in data:
    return data

    data.update(XXXXX(driver, data))

    return data


    My Dockerfile:

    FROM selenium/standalone-chrome:latest

    LABEL authors="Robert"

    # Set the working directory to /app
    WORKDIR /app

    # Copy the current directory contents into the container at /app
    COPY . /app

    # Install any needed packages specified in requirements.txt
    RUN sudo apt-get install -y python3

    RUN sudo apt-get update && sudo apt-get install -y python3-pip

    RUN sudo pip install --no-cache-dir -r requirements.txt

    # Ports
    EXPOSE 443
    EXPOSE 80

    # Define environment variable
    ENV FLASK_APP function_app.py

    # Run the Flask app
    # CMD ["flask", "run", "--host=0.0.0.0"]
    CMD ["flask", "run"]
    # ENTRYPOINT ["top", "-b"]`


    I've tried:

    • different selenium image versions;
    • different selenium images (chrome, edge, firfox, etc) also changing the corresponding webdriver instantiation in Python;
    • including my own chromedriver via the Python package chromedriver-binary;
    • removing all the chrome options I have set for in _GetDriver();
    • reverting the unrelated code chance;
    • pinging google.com from inside my API, which works showing my API can still partially access the internet

    yet to no avail.

    What is causing this and how can I fix this? Thanks in advance! <3

    Continue reading...

Compartilhe esta Página