puppeteer: [Bug]: Cannot execute chrome for testing in read only docker "--database is required"

Steps to reproduce

Dockerfile:

FROM node:18-slim
RUN npx @puppeteer/browsers install chrome@116.0.5793.0 --path /usr/bin/chrome-install

RUN apt-get update \
    && apt-get install -y wget gnupg dumb-init \
          ## chromium dependencies https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-doesnt-launch-on-linux
          ca-certificates \
          fonts-liberation \
          libasound2 \
          libatk-bridge2.0-0 \
          libatk1.0-0 \
          libc6 \
          libcairo2 \
          libcups2 \
          libdbus-1-3 \
          libexpat1 \
          libfontconfig1 \
          libgbm1 \
          libgcc1 \
          libglib2.0-0 \
          libgtk-3-0 \
          libnspr4 \
          libnss3 \
          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 \
          lsb-release \
          wget \
          xdg-utils \
      && apt-get update

ENTRYPOINT [ "/bin/bash", "-c" ]

CMD ["bash"]

In the terminal:

$ docker build -t test-puppeteer -f Dockerfile . && docker run --read-only -it test-puppeteer   bash
## inside docker
$ /usr/bin/chrome-install/chrome/linux-116.0.5793.0/chrome-linux64/chrome

Expected results

I should be able to run the browser. Before chrome testing, I was using chromium and it was possible.

Actual results

I get the following error

chrome_crashpad_handler: --database is required
Try 'chrome_crashpad_handler --help' for more information.
Trace/breakpoint trap (core dumped)
root@27814e039735:/# 
exit

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (1 by maintainers)

Commits related to this issue

Most upvoted comments

We got this to work by setting in the environment:

XDG_CONFIG_HOME=/tmp/.chromium
XDG_CACHE_HOME=/tmp/.chromium

If anyone is coming to this issue because they encounter a Puppeteer/Chrome issue with the --database flag when running CI/CD on a Jenkins Pipeline + Docker on a linux host, then the solution from @sfc-gh-selee works. In my case:

XDG_CONFIG_HOME="$WORKSPACE@tmp/.chromium"
XDG_CACHE_HOME="$WORKSPACE@tmp/.chromium"

@agrinko This command is setting environment variables and then running the chromium-browser command.

XDG_CONFIG_HOME and XDG_CACHE_HOME are environment variables defined by the XDG Base Directory Specification. This specification defines standard locations for various types of files, such as configuration files and cached data.

  • XDG_CONFIG_HOME is used to specify the base directory for user-specific configuration files. If this environment variable is not set, the default location is ~/.config.

  • XDG_CACHE_HOME is used to specify the base directory for user-specific non-essential (cached) data. If this environment variable is not set, the default location is ~/.cache.

In this command, both XDG_CONFIG_HOME and XDG_CACHE_HOME are being set to /tmp/.chromium. This means that when chromium-browser is run, it will store its configuration files and cached data in /tmp/.chromium instead of the default locations.

This can be useful in a number of scenarios. For example, if you’re running Chromium in a Docker container, you might want to store these files in a temporary directory that gets cleaned up when the container is stopped. Or, you might want to isolate the Chromium files from the rest of your system for testing or debugging purposes.

@sfc-gh-selee thank you so much! 👍 I’ve spent several days fighting with a similar issue. In my case, a docker container with Puppeteer worked fine locally (when running with Docker Desktop), but failed when deployed on an actual environment via Kubernetes. I couldn’t figure out the root cause until I tried these magic variables. I’m still not sure what they do but I’ll always keep them with me, just in case 😅