Chromium/Chrome fails to start inside Docker container (FailedToStartBrowser) #308
-
Description of the IssueI am attempting to run pydoll inside a Docker container, but the embedded browser (Chrome/Chromium) never starts. I consistently receive the following error: This happens even after installing Chrome Stable, Chromium, Firefox ESR, xvfb, and all required browser dependencies. Full Error LogsError 1Error 2 (minimal example)Minimal Reproducible Codeimport asyncio
from pydoll.browser.chromium import Chrome
async def main():
async with Chrome() as browser:
tab = await browser.start()
await tab.go_to("https://github.com/autoscrape-labs/pydoll")
star_button = await tab.find(
tag_name="button",
timeout=5,
raise_exc=False
)
if not star_button:
print("Button not found.")
return
await star_button.click()
await asyncio.sleep(3)
asyncio.run(main())Dockerfile UsedFROM python:3.12-bookworm
WORKDIR /app
COPY . .
RUN apt-get update \
&& apt-get install -y \
git-all iproute2 build-essential zlib1g-dev \
libncurses5-dev libgdbm-dev libnss3-dev libssl-dev \
libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev \
libfontconfig1 libdbus-glib-1-2 libx11-xcb1 \
xvfb firefox-esr \
&& apt-get autoremove -yqq --purge \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Google Chrome Stable
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" \
> /etc/apt/sources.list.d/google-chrome.list
RUN apt-get update && apt-get install -y google-chrome-stable --no-install-recommends
RUN apt-get update && apt-get install -y chromium --no-install-recommends
RUN pip install --upgrade pip \
&& pip install -r requirements.txt \
&& pip install torch==2.3.0+cpu torchvision==0.18.0+cpu --extra-index-url https://download.pytorch.org/whl/cpu \
&& pip install docling==2.43.0
# Playwright (for comparison/testing)
RUN playwright install chromium \
&& playwright install-deps chromiumExpected BehaviorChromium/Chrome should start normally inside the container and allow Observed BehaviorThe browser process attempts to start but apparently crashes or exits before pydoll can connect. pydoll eventually raises: This occurs even with:
Additional Notes
Possible Causes (Hypotheses)
Questions for the Maintainers
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
❓ Does anyone have a working Dockerfile?I'm running into the exact same issue when trying to use Pydoll inside a Docker container. Dockerfile I'm usingFROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive
# install python
RUN apt-get update && apt-get install -y \
python3 python3-pip python3-venv wget pipx
# create virtual env
RUN python3 -m venv /venv
ENV PATH="/venv/bin:$PATH"
# install chrome
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
apt-get install -y ./google-chrome-stable_current_amd64.deb || true && \
apt --fix-broken install -y && \
rm google-chrome-stable_current_amd64.deb
WORKDIR /app
RUN pip install --upgrade pip wheel
RUN pip install pydoll-python
COPY . /app/
ENV PYTHONPATH=/appTest codeimport asyncio
from pydoll.browser.chromium import Chrome
async def main():
print("Starting browser...")
async with Chrome() as browser:
tab = await browser.start(headless=True)
print("Browser started. Navigating to GitHub...")
await tab.go_to('https://github.com/autoscrape-labs/pydoll')
star_button = await tab.find(
tag_name='button',
timeout=5,
raise_exc=False
)
if not star_button:
print("Button not found.")
return
await star_button.click()
print("Button clicked successfully!")
await asyncio.sleep(3)
asyncio.run(main())Error❗ SummaryEverything installs fine, but Pydoll is unable to start Chrome inside Docker. |
Beta Was this translation helpful? Give feedback.
-
|
Resolvi adicionando essas parametros na config do browser: options.add_argument('--no-sandbox') |
Beta Was this translation helpful? Give feedback.
Resolvi adicionando essas parametros na config do browser:
options.add_argument('--no-sandbox')
options.add_argument('--disable-gpu')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--no-zygote')
options.add_argument('--disable-setuid-sandbox')