Open traveling-developer opened 4 years ago
Hi @yudansha , Can you share your Dockerfile so we can see the base image and try to reproduce? Thanks.
Also it's possible that you need the noSandboxFlag: true
parameter on the launch method.
Hi @xvrh, thanks for your fast reply. As you see above I already set this flag to true. I tried it now with installing chrome and setting the path as an argument. This works, but it would be nice to know why the default way does not work. Here my docker file:
FROM ubuntu:20.10
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
RUN apt-get update && \
apt-get -y install \
zip \
unzip \
curl \
poppler-utils \
default-jre-headless
# add files
ADD /scripts/generate.sh /home
RUN chmod +x /home/generate.sh
RUN mkdir -p /home/generator
ADD /scripts/PdfHandout.jar /home/generator
RUN mkdir -p /home/converter
ADD /src/workshop_builder /home/converter
RUN chmod +x /home/converter/workshop_builder
WORKDIR /home/converter
RUN mkdir -p /home/output
RUN mkdir -p /home/input
RUN mkdir -p /home/generated
WORKDIR /home
Hi!
I'm running into the same issue. I'm using the following Dockerfile:
FROM google/dart
WORKDIR /app
RUN apt-get update && apt-get install -y unzip
ADD pubspec.* /app/
RUN pub get
ADD . /app
RUN pub get --offline
CMD []
ENTRYPOINT ["dart", "./bin/importer.dart"]
I'm running the app in the Dart VM. I'm launching puppeteer without any options:
var browser = await puppeteer.launch();
On a docker container with chromium installed when you try to run on bash chromium-browser
You get the following error: Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
So launching puppeteer as:
puppeteer.launch(
headless: true,
args: ['--no-sandbox'],
);
Launches puppeteer correctly. Running it as non root user should not need the no sandbox flag
Installing Chromium in the container fixes the issue for me. I'm a bit confused though, as there is also a local-chromium installed. Why would I need Chromium installed as well?
Thanks!
@derkweijers This is the way it was solved on a a popular node dockerfile https://github.com/buildkite/docker-puppeteer/issues/91#issuecomment-618824443:
Unfortunately we need to install Chromium, because otherwise you miss out on all the dependencies that are required by the bundled node binary. I've added a note here to hopefully explain the issue: https://github.com/buildkite/docker-puppeteer/blob/master/Dockerfile#L13-L18
Thanks! It's running in production for a few days now without problems. For me, this issue is solved.
I encountered this problem on Ubuntu 20.04, then I tried to run chrome in .local-chromium directly, I found that some so files such as libatk and libgdm were missing, then I installed these dependencies by apt install, the problem solved.
问题完美解决了!(我是在树莓派上遇到的这个问题,mac上是没有这个问题的)
让我们来分析下这个问题。
通过看源码以及对比mac上可以猜测出应该是puppeteer准备下载chromium的时候没有找到对应当前操作系统的chromium版本。所以也就无法去下载了,也就没有后续了。(puppeteer应该只是准备了mac,windows,linux等主流操作系统的chromium版本,所以当遇到树莓派等其他操作系统的时候就找不到合适的chromium包了,所以出现该错误)
知道了问题所在就很简单了,我们知道puppeteer.launch的时候有个executablePath的入参,这个是关键,那我们可以在树莓派上自己安装chromium-browser版本,然后指定到我们的chromium-browser即可
sudo apt install chromium-browser -y # 安装完成后路径是 /usr/bin/chromium-browser
安装完成后指定executablePath
browser = await puppeteer.launch(
headless: true,
noSandboxFlag: true,
executablePath: '/usr/bin/chromium-browser',
args: [
'--use-fake-ui-for-media-stream',
'--disable-setuid-sandbox',
'--no-sandbox'
]);
That‘s the way to solve this problem and I trust it works for you too!
I build a small dart console app and compiled it via dart2native. Everything works fine until puppeteer starts up. I see in the docker that chrome is downloaded and the folder .local-chromium is created.
But nevertheless I get the exception: 'Exception: Websocket url not found' Is there something missing?
I call puppeteer as following: