docs(docker): update docker documentation to inlcude java (#6102)

This commit is contained in:
Yury Semikhatsky 2021-04-06 15:58:07 -07:00 committed by GitHub
parent 9abed11782
commit f61ec3fd07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,26 +3,32 @@ id: docker
title: "Docker"
---
[Dockerfile.bionic](https://github.com/microsoft/playwright/blob/master/utils/docker/Dockerfile.bionic) and [Dockerfile.focal](https://github.com/microsoft/playwright/blob/master/utils/docker/Dockerfile.focal) can be used to run Playwright scripts in Docker environments. These images includes all the dependencies needed to run browsers in a Docker container, and also include the browsers themselves.
[Dockerfile.focal] can be used to run Playwright scripts in Docker environment. These image includes all the dependencies needed to run browsers in a Docker container, and also include the browsers themselves.
<!-- TOC -->
## Usage
[![docker hub](https://img.shields.io/badge/docker-mcr.microsoft.com%2Fplaywright-blue)](https://hub.docker.com/_/microsoft-playwright)
This image is published on [Docker Hub](https://hub.docker.com/_/microsoft-playwright).
This image is published on [Docker Hub].
### Pull the image
```
```sh js python csharp
docker pull mcr.microsoft.com/playwright:focal
```
or pinned to a specific Playwright version (recommended). Replace 1.9.0 with your Playwright version:
```sh java
docker pull mcr.microsoft.com/playwright/java:focal
```
```sh
docker pull mcr.microsoft.com/playwright:v1.9.0-focal
or pinned to a specific Playwright version (recommended). Replace 1.10.0 with your Playwright version:
```sh js python csharp
docker pull mcr.microsoft.com/playwright:v1.10.0-focal
```
```sh java
docker pull mcr.microsoft.com/playwright/java:v1.10.0-focal
```
### Run the image
@ -33,18 +39,26 @@ By default, the Docker image will use the `root` user to run the browsers. This
On trusted websites, you can avoid creating a separate user and use root for it since you trust the code which will run on the browsers.
```
```sh js python csharp
docker run -it --rm --ipc=host mcr.microsoft.com/playwright:focal /bin/bash
```
```sh java
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:focal /bin/bash
```
#### Crawling and scraping
On untrusted websites, it's recommended to use a separate user for launching the browsers in combination with the seccomp profile. Inside the container or if you are using the Docker image as a base image you have to use `adduser` for it.
```
```sh js python csharp
$ docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright:focal /bin/bash
```
```sh java
$ docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/java:focal /bin/bash
```
[`seccomp_profile.json`](https://github.com/microsoft/playwright/blob/master/utils/docker/seccomp_profile.json) is needed to run Chromium with sandbox. This is a [default Docker seccomp profile](https://github.com/docker/engine/blob/d0d99b04cf6e00ed3fc27e81fc3d94e7eda70af3/profiles/seccomp/default.json) with extra user namespace cloning permissions:
```json
@ -75,51 +89,46 @@ See our [Continuous Integration guides](./ci.md) for sample configs.
## Image tags
See [all available image tags](https://mcr.microsoft.com/v2/playwright/tags/list).
See [all available image tags].
Docker images are published automatically by GitHub Actions. We currently publish images with the
following tags (`v1.10.0` in this case is an example:):
- `:next` - tip-of-tree image version based on Ubuntu 20.04 LTS.
- `:next-focal` - tip-of-tree image version based on Ubuntu 20.04 LTS.
- `:next-bionic` - tip-of-tree image version based on Ubuntu 18.04 LTS.
- `:bionic` - last Playwright release docker image based on Ubuntu 18.04 LTS.
- `:focal` - last Playwright release docker image based on Ubuntu 20.04 LTS (Focal Fossa).
- `:v1.10.0` - Playwright v1.10.0 release docker image based on Ubuntu 20.04 LTS (Focal Fossa).
- `:v1.10.0-focal` - Playwright v1.10.0 release docker image based on Ubuntu 20.04 LTS (Focal Fossa).
- `:v1.10.0-bionic` - Playwright v1.10.0 release docker image based on Ubuntu 18.04 LTS (Bionic Beaver).
- `:sha-XXXXXXX` - docker image for every commit that changed
docker files or browsers, marked with a [short sha](https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#Short-SHA-1) (first 7 digits of the SHA commit).
Status of push to MCR can be [verified here](https://mcrflow-status-ui.azurewebsites.net/) (internal link).
### Base images
We currently publish images based on the following [Ubuntu](https://hub.docker.com/_/ubuntu) versions:
- **Ubuntu 20.04 LTS** (Focal Fossa), image tags include `focal`
- **Ubuntu 18.04 LTS** (Bionic Beaver), image tags include `bionic`
#### Alpine
Browser builds for Firefox and WebKit are built for the [glibc](https://en.wikipedia.org/wiki/GNU_C_Library) library. Alpine Linux and other distributions that are based on the [musl](https://en.wikipedia.org/wiki/Musl) standard library are not supported.
## Development
* langs: js
### Build the image
Use [`//utils/docker/build.sh`](https://github.com/microsoft/playwright/blob/master/utils/docker/build.sh) to build the image.
```
$ ./utils/docker/build.sh bionic playwright:localbuild-bionic
$ ./utils/docker/build.sh focal playwright:localbuild-focal
```
The image will be tagged as `playwright:localbuild-bionic` and could be run as:
The image will be tagged as `playwright:localbuild-focal` and could be run as:
```
$ docker run --rm -it playwright:localbuild /bin/bash
```
### Push
Docker images are published automatically by GitHub Actions. We currently publish the following images. `1.9.0` in this case is an example:
- `mcr.microsoft.com/playwright:next` - tip-of-tree image version.
- `mcr.microsoft.com/playwright:next-focal` - tip-of-tree image version.
- `mcr.microsoft.com/playwright:next-bionic` - tip-of-tree image version.
- `mcr.microsoft.com/playwright:bionic` - last Playwright release docker image.
- `mcr.microsoft.com/playwright:focal` - last Playwright release docker image.
- `mcr.microsoft.com/playwright:v1.9.0` - version specific Docker image (1.9.0 is an example)
- `mcr.microsoft.com/playwright:v1.9.0-focal` - version specific Docker image (1.9.0 is an example)
- `mcr.microsoft.com/playwright:v1.9.0-bionic` - version specific Docker image (1.9.0 is an example)
- `mcr.microsoft.com/playwright:sha-XXXXXXX` - docker image for every commit that changed
docker files or browsers, marked with a [short sha](https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#Short-SHA-1) (first 7 digits of the SHA commit).
Status of push to MCR can be [verified here](https://mcrflow-status-ui.azurewebsites.net/) (internal link).
## Base images
### Ubuntu 20
`mcr.microsoft.com/playwright:focal` is based on Ubuntu 20.04 LTS (Focal Fossa).
### Ubuntu 18
`mcr.microsoft.com/playwright:bionic` is based on Ubuntu 18.04 LTS (Bionic Beaver).
### Alpine
Browser builds for Firefox and WebKit are built for the [glibc](https://en.wikipedia.org/wiki/GNU_C_Library) library. Alpine Linux and other distributions that are based on the [musl](https://en.wikipedia.org/wiki/Musl) standard library are not supported.