Unable to run headful chrome on AWS EC2 with seleniumbase while I can run it locally #3833
-
| i have this dockerfile FROM python:3.12-slim-bookworm
# Set working directory
WORKDIR /app
# Install required system dependencies
# dumb-init kill chrome zombie processes
# xvfb for headful chrome
# gnupg verify Chrome’s signing key
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        wget \
        gnupg \
        xvfb \
        dumb-init && \
    rm -rf /var/lib/apt/lists/*
# Add Google Chrome repository and install Chrome
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \
    echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \
    apt-get update && \
    apt-get install -y --no-install-recommends google-chrome-stable && \
    rm -rf /var/lib/apt/lists/*
# Create user and set permissions
RUN useradd --home-dir /app --shell /bin/sh chromeuser && \
    chown -R chromeuser:chromeuser /app
USER chromeuser
# Create Chrome config path to avoid warnings
RUN mkdir -p "/app/.config/chrome/Crash Reports/pending"
# Copy Python requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY src ./
# Ports (adjust if necessary)
EXPOSE 8191
# Default entrypoint and command
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["python", "-u", "/app/main.py"]
I have this seleniumbase script: from seleniumbase.undetected import cdp_driver
async def get_webdriver_nd(proxy_data=None) -> cdp_driver.browser.Browser:
    logging.debug("Launching web browser with nodriver...")
    proxy = None
    if type(proxy_data) is dict and proxy_data != {}:
        server = proxy_data.get("server")
        username = proxy_data.get("username")
        password = proxy_data.get("password")
        if server and username and password:
            proxy = f"{username}:{password}@{server}"
        elif server:
            proxy = server
    return await cdp_driver.cdp_util.start_async(
        proxy=proxy,
    )And I have this error   File "/app/utils.py", line 154, in get_webdriver_nd
    return await cdp_driver.cdp_util.start_async(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/seleniumbase/undetected/cdp_driver/cdp_util.py", line 428, in start_async
    return await start(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/seleniumbase/undetected/cdp_driver/cdp_util.py", line 362, in start
    driver = await Browser.create(config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/seleniumbase/undetected/cdp_driver/browser.py", line 125, in create
    await instance.start()
  File "/usr/local/lib/python3.12/site-packages/seleniumbase/undetected/cdp_driver/browser.py", line 474, in start
    raise Exception(
Exception:
                    --------------------------------
                    Failed to connect to the browser
                    --------------------------------I am unable to run headful chrome on production AWS EC2 with seleniumbase while I can make it work locally | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
| Any "slim" Dockerfile is going to be missing important dependencies, eg: https://stackoverflow.com/a/49710327/7058266. Note that there's already a Dockerfile for regular SeleniumBase use: SeleniumBase/Dockerfile. However, Docker leaves a detectable fingerprint, which makes Docker incompatible with UC Mode / CDP Mode. (AWS runs on a non-residential IP-range, which means running from there would be detectable.) | 
Beta Was this translation helpful? Give feedback.
Any "slim" Dockerfile is going to be missing important dependencies, eg: https://stackoverflow.com/a/49710327/7058266.
Note that there's already a Dockerfile for regular SeleniumBase use: SeleniumBase/Dockerfile.
However, Docker leaves a detectable fingerprint, which makes Docker incompatible with UC Mode / CDP Mode.
If you want to run undetectable automation on a Linux server, GitHub Actions works well for that, as discussed in my YouTube video: https://www.youtube.com/watch?v=Mr90iQmNsKM.
(AWS runs on a non-residential IP-range, which means running from there would be detectable.)