alpine-chrome icon indicating copy to clipboard operation
alpine-chrome copied to clipboard

Unable to run puppeteer with headless:false

Open littlee opened this issue 3 years ago • 1 comments

Describe the bug

(node:18) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome!
[29:29:0421/022508.111924:ERROR:browser_main_loop.cc(1390)] Unable to open X display.


TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/app/node_modules/puppeteer/lib/Launcher.js:342:14)
    at ChildProcess.<anonymous> (/app/node_modules/puppeteer/lib/Launcher.js:332:60)
    at ChildProcess.emit (events.js:327:22)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)

To Reproduce Dockerfile

FROM zenika/alpine-chrome:with-node

ENV CHROME_BIN="/usr/bin/chromium-browser"\
  PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"

WORKDIR /app

COPY --chown=chrome package.json .
COPY --chown=chrome .npmrc .

RUN npm install

ADD --chown=chrome . .

ENTRYPOINT ["tini", "--"]

CMD [ "npm", "run", "dev" ]

nodejs code

const browser = await puppeteer.launch({
      headless: false,
      executablePath: process.env.CHROME_BIN || undefined,
      args: ['--no-sandbox', '--disable-setuid-sandbox']
    });

What is the expected behavior? chromium start normally

What is the actual behavior? chromium failed to start Possible solution

Logs If applicable, add logs to help explain your problem.

Versions

Software Version(s) How-to
Chromium 89.0.4389.72 docker container run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser --version
Image sha256:7e3b38744596dacbd8d37491a206ab6fce1eb8bcbbff4b8314af92b154638887 docker image inspect --format='{{index .RepoDigests 0}}' zenika/alpine-chrome
Docker Engine 20.10.5 docker version

Additional context Add any other context about the problem here.

littlee avatar Apr 21 '21 02:04 littlee

Hi @littlee 👋

Thanks for your issue! 👍 Have you try the example with puppeteer here: https://github.com/Zenika/alpine-chrome/tree/master/with-puppeteer ?

I remind you that this image objective is to get a chromium headless based docker image. (with no display) FYI, here is an experiment with X11: https://github.com/Zenika/alpine-chrome/tree/master/examples/x11

jlandure avatar May 10 '21 09:05 jlandure