Introduction
Puppeteer is a Node.js library which provides a high-level API to control Chromium (or Firefox) browsers over the DevTools ...
For further actions, you may consider blocking this person and/or reporting abuse
After running the code and I got into multiple errors of browser not launching caused by using wrong executablePath etc, Below code help in resolving the issue
where is that
locateChrome
function tho?npmjs.com/package/locate-chrome here
Hi there, I know it's an old post, but it's still valid. I provide a config that works for image oraclelinux based on rh.
And the lunch:
Hi there,
I used your Dockerfile content along with mine as i am trying to to generate pdf file for this service that i'm building with typescript. now everything works locally but i can't deploy it to AWS as it exceeds the lambda limit. now i am trying to dockerize it and it get's deployed but throws the following error.
here is my Dockerfile
and here is my code
Hi! Here, you're using a multi-stage build in Docker. You are taken the
node:slim
image, installing puppeteer there. But then you started a new stage withFROM public.ecr.aws/lambda/nodejs:14
and you don't haveapt
or Chrome neither in this image because is based on Amazon Linux and it usesyum
as package manager (like RHEL).You can check some approaches like github.com/shelfio/chrome-aws-lamb... or github.com/alixaxel/chrome-aws-lambda that explains how to use pptr inside Lambdas.
Also, I found this here stackoverflow.com/a/66099373, but I didn't test it
i just tried this.
my Dockerfile
and my code
and i get this error
"Protocol error (Target.setAutoAttach): Target closed."
Any solution to this? Having the exact same error.
You should install all these X Window System dependencies in your Docker image:
alsa-lib
atk
cups-libs
ipa-gothic-fonts
libXcomposite
libXcursor
libXdamage
libXext
libXi
libXrandr
libXScrnSaver
libXtst
pango
xorg-x11-fonts-100dpi
xorg-x11-fonts-75dpi
xorg-x11-fonts-cyrillic
xorg-x11-fonts-misc
xorg-x11-fonts-Type1
xorg-x11-utils
Also, would have a look in here please? I'm so stuck!
stackoverflow.com/questions/737184...
updated my Dockerfile
i'm using your build and copying to my own build
but getting this error:
"Failed to launch the browser process! spawn /usr/bin/google-chrome ENOENT\n\n\nTROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md\n"
Why aren't you using the Amazon ECS?
why? so it would workout with ECS but not with lambda?
ECS was made to work with Docker images and it fits with your needs. You can run Docker images on Lambdas but I didn't see that before, maybe you will pay more if you use Lambda because the price is based on CPU and RAM consumption.
The resources required to wake up a container are much more than just running and interpreting some code, so you could end up paying more just for resources that doesn't necessarily translate to performance.
I am trying this in ECS and getting thsi error
no valid OpenPGP data found.
can someone please help
@navarroaxel - nice article - helped me even though I am using the
python
versionThanks! It works fine for me.
Thank you for this, it got me unstuck. Do you know if installing the latest Google Chrome could lead to problems if using an older version of Puppeteer? How to avoid this?
Yep, puppeteer is tested with a specific version of Chromium, details here: pptr.dev/chromium-support.
Also in each release you can see that version: github.com/puppeteer/puppeteer/rel....
You can check the available version starting a container with:
And then these commands for
chromium
orgoogle-chrome-stable
:For
node:18-slim
you'll see this output:Just look for a puppeteer version that works fine with the given Chromium version.
This saved the day! :)
I made an account just to thank You.
I have been trying to run @unlighthouse and Puppeteer in a docker for two days now, with nothing working. I installed Chrome in twenty different ways with no luck; the puppeteer couldn't spawn Chrome. Miraculously this exact snipped worked! The dopamine rush and ecstasy were something indescribable.
how ridiculously hard is it to run puppeteer on a server. my mind is bending right now.
For anyone having troubles here is my solution (That runs on my machine lul)
Dockerfile
script.js
SOLVED If you're on an M1 mac you have to add
--platform linux/amd64
to your docker build command.When I run this same docker file I receive the following error:
The entire dockerfile is:
are u fixed this issue ??
this tutorial is great. but i have an issue, when i try to install chromium in node:18-alpine3.16, i add some command like this : RUN apk add --no-cache chromium
but it still not work, chromium not installed in container. any one has tutorials or some advice?
As you working on puppeteer, and if you suffer from zombie process then use below docker commands , it will not create zombie process
FROM node:18-slim
RUN apt-get update
RUN apt-get upgrade
RUN apt-get update && apt-get install curl gnupg -y \
&& curl --location --silent dl-ssl.google.com/linux/linux_sign... | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install google-chrome-stable -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && \
apt-get upgrade && apt-get install -y vim
ADD ./puppetron.tar /usr/share/
WORKDIR /usr/share/puppetron
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV SERVICE_PATH=/usr/share/puppetron
CMD node main.js;
And path of browser
executablePath: '/usr/bin/google-chrome',
Getting this error - ****
Error: Failed to launch the browser process!
[74:122:0316/214552.693705:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[0316/214552.821672:ERROR:scoped_ptrace_attach.cc(27)] ptrace: Function not implemented (38)
Assertion failed: p_rcu_reader->depth != 0 (/qemu/include/qemu/rcu.h: rcu_read_unlock: 102)
TROUBLESHOOTING: pptr.dev/troubleshooting
at ChildProcess.onClose (/work/node_modules/@puppeteer/browsers/lib/cjs/launch.js:277:24)
at ChildProcess.emit (node:events:530:35)
at ChildProcess._handle.onexit (node:internal/child_process:294:12)
{"success":false,"data":"{\"status\":\"\",\"headers\":[],\"content\":\"\",\"trace\":\"PUPPET_LOG: INPUT_JSON = {\"url\":\"example.com\",\"user_agent\"...} StartLoading > ERROR > Cannot read properties of undefined (reading 'newPage')\"}"}TypeError: Cannot read properties of undefined (reading 'close')
at closeBrowser (/work/download_page_html.js:330:24)
at killProcess (/work/download_page_html.js:345:8)
at outputResult (/work/download_page_html.js:378:3)
at /work/download_page_html.js:367:4
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
My docker file looks like - FROM --platform=linux/amd64 node:20
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV PUPPETEER_SKIP_DOWNLOAD true
RUN apt-get update && apt-get install curl gnupg -y \
&& curl --location --silent dl-ssl.google.com/linux/linux_sign... | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install google-chrome-stable -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /work
COPY package.json ./
RUN npm install
RUN npx puppeteer browsers install chrome
COPY app.js download_page_html.js crawler-browser.js start-crawler-browser.sh start-download-page-html.sh ./
EXPOSE 3000
And I am using Apple M1 laptop
When I try to use the docker file above to build an image, I get
#5 7.862 E: Unable to locate package google-chrome-stable
Works for me using this Dockerfile gist.github.com/navarroaxel/3f4492..., I built it with
Are you using another base image instead of
FROM node:slim AS app
?Wonderful, thanks!
I had to add
ENV PUPPETEER_SKIP_DOWNLOAD true
to the env variables.ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
wasn't enough.Thank you, after so much searching I found the correct solution.
what is your solution, can you post ?
Can anyone give dockerfile to work with puppeteer under python? I can't find one working correctly anywhere.
Here is a working docker file for an arm based docker image.
thanks for updating the article. 💗