Skip to main content
Version: 22.6.1

Docker

Puppeteer 提供了一个 Docker 映像,其中包含 用于测试的 Chrome 以及所需的依赖和预安装的 Puppeteer 版本。该图片可通过 GitHub 容器注册表 获取。最新图片标记为 latest,其他标记与 Puppeteer 版本匹配。例如,

¥Puppeteer offers a Docker image that includes Chrome for Testing along with the required dependencies and a pre-installed Puppeteer version. The image is available via the GitHub Container Registry. The latest image is tagged as latest and other tags match Puppeteer versions. For example,

docker pull ghcr.io/puppeteer/puppeteer:latest # pulls the latest
docker pull ghcr.io/puppeteer/puppeteer:16.1.0 # pulls the image that contains Puppeteer v16.1.0

该映像用于在沙箱模式下运行浏览器,因此运行该映像需要 SYS_ADMIN 功能。

¥The image is meant for running the browser in sandbox mode and therefore, running the image requires the SYS_ADMIN capability.

用法

¥Usage

要直接使用 docker 镜像,请运行:

¥To use the docker image directly, run:

docker run -i --init --cap-add=SYS_ADMIN --rm ghcr.io/puppeteer/puppeteer:latest node -e "$(cat path/to/script.js)"

其中 path/to/script.js 是相对于你的工作目录的路径。请注意,由于浏览器在沙盒模式下运行,因此该图片需要 SYS_ADMIN 功能。

¥where path/to/script.js is the path relative to your working directory. Note the image requires the SYS_ADMIN capability since the browser runs in sandbox mode.

如果你需要基于不同的基础镜像构建镜像,你可以使用我们的 Dockerfile 作为起点。

¥If you need to build an image based on a different base image, you can use our Dockerfile as the starting point.