I am new to puppeteer and docker. I am facing an issue while setting up puppeteer in headful mode in docker container.
Puppeteer version: 1.6.2 Platform / OS version: Docker node:8-slim Node.js version: node 8
DockerFile -
FROM node:8-slim
RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates curl fontconfig fonts-liberation gconf-service git libappindicator1 libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 locales lsb-release unzip wget xdg-utils
RUN apt-get update && apt-get install -y wget --no-install-recommends && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && apt-get update && apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont --no-install-recommends && rm -rf /var/lib/apt/lists/* \
&& apt-get purge --auto-remove -y curl && rm -rf /src/*.deb
ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser && mkdir -p /home/pptruser/Downloads && chown -R pptruser:pptruser /home/pptruser && chown -R pptruser:pptruser .
USER pptruser
EXPOSE 4081/tcp
CMD [ "npm", "start" ]
Application code:
const browser = await puppeteer.launch({
headless: false,
args:['--no-sandbox']
});
I am using puppeteer to take screenshot of the url provided. It executes successfully in headless true mode. But, when same script executed with headless false, it gives errors as:
Error: Failed to launch chrome! [0803/070106.562113:ERROR:nacl_helper_linux.cc(310)] NaCl helper process running without a sandbox!
[11104:11104:0816/105455.434188:FATAL:zygote_host_impl_linux.cc(123)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox
Could you please help with this issue. Or could you share a sample application code which uses puppeteer for screenshot in docker container in headful mode. Reason for using headful mode: better performance and some sites don't allow
Check the following
Dockerfile
, read the comments. It should run properly.Then I run it with following command,
Sample result from our script that I used above, it can be any script,