I’m having trouble with Puppeteer and Firefox in a Docker setup. My container won’t run in headless mode. It keeps throwing an error about a missing DISPLAY environment variable.
Here’s what I’ve tried:
Set up a Dockerfile with Node.js, Firefox, and necessary libraries
Installed Puppeteer and skipped Chromium download
Set HEADLESS to true in environment variables
Tried to start Xvfb in the container
But nothing’s working. The error message is always the same:
Failed to launch the browser process!
Error: no DISPLAY environment variable specified
I’m out of ideas. Has anyone faced this before? What am I missing? Any tips on how to get Firefox Puppeteer running smoothly in a Docker container would be great. Thanks!
I’ve encountered this issue before. The key is to ensure you’re using the correct Firefox binary path in your Puppeteer configuration. Try adding this to your code:
Also, double-check that you’ve installed firefox-esr in your Dockerfile:
RUN apt-get update && apt-get install -y firefox-esr
If you’re still having trouble, consider using the puppeteer-firefox package instead of regular Puppeteer. It’s specifically designed for Firefox and might handle these edge cases better. Hope this helps!