To run Puppeteer in a Docker container, you can follow these steps:
FROM node:14
RUN apt-get update && apt-get install -y \
gconf-service \
libasound2 \
libatk1.0-0 \
libcups2 \
libdbus-1-3 \
libgconf-2-4 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libx11-xcb1 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
xdg-utils
WORKDIR /app
COPY package.json .
COPY package-lock.json .
RUN npm install
COPY . .
CMD ["node", "your_script.js"]
docker build -t puppeteer-docker .
docker run -it puppeteer-docker
This will start a Docker container with Puppeteer installed, and it will run the script defined in your Dockerfile (Replace "your_script.js" with the name of your Puppeteer script).
That's it! You have successfully run Puppeteer in a Docker container.