admin管理员组文章数量:1123404
I am trying to run Puppeteer using Firefox in a Docker container. Below is my Dockerfile:
# Use the official Node.js Docker image as the base image
FROM node:slim
# We don't need the standalone Chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
# Install Firefox and necessary libraries
RUN apt-get update && apt-get install -y \
wget \
gnupg \
firefox-esr \
libgtk-3-0 \
libdbus-glib-1-2 \
libxt6 \
libasound2 \
libnss3 \
libxss1 \
xdg-utils \
xvfb \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json to the container
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code to the container
COPY . .
# Environment variables
ENV HEADLESS true
ENV DEFAULT_PUPPETEER_TIMEOUT 15000
# Command to start the application
CMD ["npm", "start"]
When I run the container, I get the following error:
`error: Error during replayJson execution: Failed to launch the browser process!
Error: no DISPLAY environment variable specified`
The HEADLESS environment variable is set to true. I also tried starting Xvfb in the container by adding the following to the Dockerfile:
`CMD ["sh", "-c", "Xvfb :99 -screen 0 1920x1080x24 & npm start"]`
However, the issue persists.
How can I resolve the no DISPLAY environment variable specified error for Puppeteer with Firefox in Docker?
本文标签:
版权声明:本文标题:dockerfile - Docker Puppeteer with Firefox: Error "no DISPLAY environment variable specified" when running in 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736567650a1944727.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论