Running headless Chrome / Puppeteer with --no-sandbox Running headless Chrome / Puppeteer with --no-sandbox docker docker

Running headless Chrome / Puppeteer with --no-sandbox


I was hitting a similar problem trying to run Chromium headless in an Alpine Docker container, and apparently so are many other (e.g., here, here). The --no-sandbox option is a straightforward workaround but obviously a poor security practice. What worked for me was setting a custom seccomp.

Download this file (if interested, see the author's notes here). Then pass the option --security-opt seccomp=path/to/chrome.json when starting Docker, or specify the same option in your docker-compose.yml if you're using one.


In your nodejs code when you launch your browser, you can pass the --no-sandbox argument.

example:-

const launchBrowser = async () => {  puppetBrowser = await puppeteer.launch({    args: ['--no-sandbox'],    timeout: 10000,  });};


There is no need of a timeout,

const browser = await puppeteer.launch({headless: true, args:['--no-sandbox']});