Debian Docker K8s의 Puppeteer/Chromium: "X11 연결을 열 수 없습니다."

Debian Docker K8s의 Puppeteer/Chromium: "X11 연결을 열 수 없습니다."

이것이 나를 미치게 만들고 있습니다. 인형극 실행 구성으로 헤드리스 크롬 인스턴스를 실행하는 것이 그렇게 어려울 것이라고는 예상하지 못했습니다.

오류는 다음과 같습니다.

# launching puppeteer with config {"args":["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage","--disable-accelerated-2d-canvas","--no-first-run","--no-zygote","--single-process","--disable-gpu","--headless"],"headless":true,"devtools":false,"timeout":90000,"executablePath":"/usr/bin/chromium","dumpio":true}
[0124/153812.589239:ERROR:browser_main_loop.cc(536)] Failed to open an X11 connection.
[0124/153812.590155:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
xcb_connection_has_error() returned true
[0124/153812.592511:WARNING:audio_manager_linux.cc(69)] Falling back to ALSA for audio output. PulseAudio is not available or could not be initialized.

이것은 내 Dockerfile입니다.

FROM node:16.13

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium

RUN apt-get update \
    && apt-get install -yq wget curl gnupg libgconf-2-4 ca-certificates wget xvfb dbus dbus-x11 build-essential --no-install-recommends

RUN apt-get update && apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 \
    libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 \
    libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 \
    libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
    libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 \
    libxss1 libxtst6 ca-certificates fonts-liberation libnss3 lsb-release \
    xdg-utils wget

RUN apt-get update && apt-get install gnupg wget -y && \
    wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
    sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
    apt-get update && \
    apt-get install chromium fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 dbus-x11 -y --no-install-recommends && \
    rm -rf /var/lib/apt/lists/\*

RUN mkdir -p /usr/src/app
VOLUME ["/usr/src/app"]
WORKDIR /usr/src/app

COPY . /usr/src/app

RUN yarn install

RUN chmod -R 777 /usr/src/app

ENTRYPOINT [ "./entrypoint.sh" ]
EXPOSE 80

이 내 꺼야 entrypoint.sh:

#!/bin/bash

# Startup Xvfb
Xvfb -ac :99 -screen 0 1280x1024x16 > /dev/null 2>&1 &

# Export some variables
export DISPLAY=:99.0

npm run-script deploy-force && npm start && sleep 6000

이것은 내 Puppeteer 구성입니다.

const puppeteerConfig = {
    args: [
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--disable-dev-shm-usage',
        '--disable-accelerated-2d-canvas',
        '--no-first-run',
        '--no-zygote',
        '--single-process', // <- this one doesn't works in Windows
        '--disable-gpu',
        '--headless'
    ],
    headless: true,
    devtools: false,
    timeout: 90000,
    executablePath: '/usr/bin/chromium',
    dumpio: true
};

Xvfbx11 연결을 실행하면 그런 일이 일어날 것이라고 생각했습니까 ?

관련 정보