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)
Links to this issue
Commits related to this issue
- fix puppeteer start error during ci tests Error: Error: Failed to launch the browser process! Error: chrome_crashpad_handler: --database is required - https://github.com/puppeteer/puppetee... — committed to sni/thruk by sni 2 years ago
- fix: give puppeteer a place to dump its stuff https://github.com/puppeteer/puppeteer/issues/11023#issuecomment-1776247197 — committed to bcgov/EDUC-CCOF by trev-dev 2 years ago
- fix?: set an XDG environment, prevent chrome crash https://github.com/puppeteer/puppeteer/issues/11023#issuecomment-1776247197 — committed to bcgov/EDUC-CCOF by trev-dev 2 years ago
- Fix headless puppeteer Not required in a nixos test, but required on a headless server. See <https://github.com/puppeteer/puppeteer/issues/11023#issuecomment-1776247197>. — committed to ptitfred/personal-infrastructure by ptitfred 2 years ago
- Fix Chromium crashpad issue using writable tmp directories (puppeteer/puppeteer#11023) — committed to energychain/banedon_browser by invalid-email-address a year ago
We got this to work by setting in the environment:
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:
@agrinko This command is setting environment variables and then running the
chromium-browsercommand.XDG_CONFIG_HOMEandXDG_CACHE_HOMEare 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_HOMEis 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_HOMEis 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_HOMEandXDG_CACHE_HOMEare being set to/tmp/.chromium. This means that whenchromium-browseris run, it will store its configuration files and cached data in/tmp/.chromiuminstead 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 😅