I'm unable to launch a new page using Puppeteer within Docker, on an M1 Mac.
Versions
Docker: version 20.10.11, build dea9396
Node: 16.13.1
MacOS: 12.0.1 (21A559)
Puppeteer: 13.5.1
M1 Chip
Error Message
ProtocolError: Protocol error (Target.createTarget): Target closed.
at /home/node/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:75:24
at new Promise (<anonymous>)
at Connection.send (/home/node/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:71:16)
at Browser._createPageInContext (/home/node/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Browser.js:261:53)
at BrowserContext.newPage (/home/node/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Browser.js:520:30)
at Browser.newPage (/home/node/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Browser.js:254:37)
at /home/node/app/src/test.js:17:19
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Script
const puppeteer = require('puppeteer');
(async function () {
const browser = await puppeteer.launch({
headless: true,
args: [
'--disable-gpu', // if i remove this, strangely the process exits unexpectedly
'--disable-dev-shm-usage',
'--no-sandbox',
'--disable-setuid-sandbox',
],
});
await browser.newPage();
})();
Dockerfile (relevant info)
FROM --platform=linux/amd64 node:16.13.1-slim
# Server Dependencies (changed less often)
RUN apt-get update && \
apt-get -y install vim xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
libgtk-3-0 libnspr4 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 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
RUN apt-get install -y python make g++
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 /home/node/app
USER pptruser
❯ docker version
Client:
Cloud integration: v1.0.22
Version: 20.10.11
API version: 1.41
Go version: go1.16.10
Git commit: dea9396
Built: Thu Nov 18 00:36:09 2021
OS/Arch: darwin/arm64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.11
API version: 1.41 (minimum version 1.12)
Go version: go1.16.9
Git commit: 847da18
Built: Thu Nov 18 00:34:44 2021
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.4.12
GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0
npm install --save [email protected]
, but this command is not included in your Dockerfile in the question. – Sociologydocker version
, pls? – Sociology