haydnba / docker-puppeteer

Dockerfile and example script for containerised puppeteer...

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Secure headful docker puppeteer

Run containerised puppeteer chrome as securely as possible (e.g. for testing untrusted domains), plus enable headful execution with Xvfb frame buffer.

Context

Official puppeteer documentation "strongly discourages" the very common use of --no-sandbox flag with dockerised puppeteer on security grounds, yet appears to recommend creating a non-privileged user and passing the equally suspect --cap-add=SYS_ADMIN flag to docker run command.

Generally the best option appears to be to use a custom "seccomp" profile (see here) - this is the pattern adopted/recommended by the playwright team among others.

Implementation here follows the Playwright method of cloning the docker default seccomp profile and adding a specific namespacing rule:

{
  "comment": "Allow create user namespaces",
  "names": ["clone", "setns", "unshare"],
  "action": "SCMP_ACT_ALLOW",
  "args": [],
  "includes": {},
  "excludes": {}
}

An alternative is to use the Chrome seccomp profile provided by Jess Frazelle here

Resources

Run app locally

npm run start

Run dockerised app locally

# Use the script
chmod u+x ./bin/run.sh
./bin/run.sh

About

Dockerfile and example script for containerised puppeteer...


Languages

Language:Dockerfile 48.4%Language:JavaScript 32.9%Language:Shell 18.7%