Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add documentation about Docker #8741

Merged
merged 1 commit into from Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Expand Up @@ -198,6 +198,26 @@ See [`Page.evaluate`](https://pptr.dev/api/puppeteer.page.evaluate) and related

<!-- [END getstarted] -->

### Running in Docker

Puppeteer offers a Docker image that includes Chromium along with the required dependencies and a pre-installed Puppeteer version. The image is available via the [GitHub Container Registry](https://github.com/puppeteer/puppeteer/pkgs/container/puppeteer). The latest image is tagged as `latest` and other tags match Puppeteer versions. For example,

```sh
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
```

The image is meant for running the browser in the sandobx mode and therefore, running the image requires the `SYS_ADMIN` capability. For example,

```sh
docker run -i --init --cap-add=SYS_ADMIN --rm ghcr.io/puppeteer/puppeteer:latest node -e "`cat docker/test/smoke-test.js`"
```

Replace the path to [`smoke-test.js`](https://raw.githubusercontent.com/puppeteer/puppeteer/main/docker/test/smoke-test.js) with a path to your script.
The script can import or require the `puppeteer` module because it's pre-installed inside the image.

Currently, the image includes the LTS version of Node.js. If you need to built an image based on a different base image, you can use our [`Dockerfile`](https://github.com/puppeteer/puppeteer/blob/main/docker/Dockerfile) as the starting point.

### Working with Chrome Extensions

Puppeteer can be used for testing Chrome Extensions.
Expand Down
4 changes: 4 additions & 0 deletions docker/README.md
Expand Up @@ -17,3 +17,7 @@ docker run -i --init --rm --cap-add=SYS_ADMIN --name puppeteer-chrome puppeteer-
```

`--cap-add=SYS_ADMIN` capability is needed to enable Chromium sandbox that makes the browser more secure. Alternatively, it should be possible to start the browser binary with the `--no-sandbox` flag.

## GitHub Actions

The image is automatically built, tested, and published by the [publish-docker.yml](https://github.com/puppeteer/puppeteer/blob/main/.github/workflows/publish-docker.yml) workflow.
20 changes: 20 additions & 0 deletions docs/index.md
Expand Up @@ -204,6 +204,26 @@ See [`Page.evaluate`](https://pptr.dev/api/puppeteer.page.evaluate) and related

<!-- [END getstarted] -->

### Running in Docker

Puppeteer offers a Docker image that includes Chromium along with the required dependencies and a pre-installed Puppeteer version. The image is available via the [GitHub Container Registry](https://github.com/puppeteer/puppeteer/pkgs/container/puppeteer). The latest image is tagged as `latest` and other tags match Puppeteer versions. For example,

```sh
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
```

The image is meant for running the browser in the sandobx mode and therefore, running the image requires the `SYS_ADMIN` capability. For example,

```sh
docker run -i --init --cap-add=SYS_ADMIN --rm ghcr.io/puppeteer/puppeteer:latest node -e "`cat docker/test/smoke-test.js`"
```

Replace the path to [`smoke-test.js`](https://raw.githubusercontent.com/puppeteer/puppeteer/main/docker/test/smoke-test.js) with a path to your script.
The script can import or require the `puppeteer` module because it's pre-installed inside the image.

Currently, the image includes the LTS version of Node.js. If you need to built an image based on a different base image, you can use our [`Dockerfile`](https://github.com/puppeteer/puppeteer/blob/main/docker/Dockerfile) as the starting point.

### Working with Chrome Extensions

Puppeteer can be used for testing Chrome Extensions.
Expand Down
1 change: 1 addition & 0 deletions docs/troubleshooting.md
Expand Up @@ -249,6 +249,7 @@ Running Puppeteer smoothly on CircleCI requires the following steps:
## Running Puppeteer in Docker

> 👋 We used [Cirrus Ci](https://cirrus-ci.org/) to run our tests for Puppeteer in a Docker container until v3.0.x - see our historical [`Dockerfile.linux` (v3.0.1)](https://github.com/puppeteer/puppeteer/blob/v3.0.1/.ci/node12/Dockerfile.linux) for reference.
> Starting from v16.0.0 we are shipping a Docker image via the GitHub registry. The Dockerfile is located [here](https://github.com/puppeteer/puppeteer/blob/main/docker/Dockerfile) and the usage instructions are in the [README.md](https://github.com/puppeteer/puppeteer#running-in-docker). The instructions below might be still helpful if you are building your own image.
Getting headless Chrome up and running in Docker can be tricky.
The bundled Chromium that Puppeteer installs is missing the necessary
Expand Down