Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alekzonder/docker-puppeteer
docker image with Google Puppeteer installed
https://github.com/alekzonder/docker-puppeteer
docker docker-image google-puppeteer puppeteer screenshot
Last synced: 2 months ago
JSON representation
docker image with Google Puppeteer installed
- Host: GitHub
- URL: https://github.com/alekzonder/docker-puppeteer
- Owner: alekzonder
- License: mit
- Created: 2017-08-18T11:40:14.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-10-20T06:08:42.000Z (about 3 years ago)
- Last Synced: 2024-09-30T15:22:09.569Z (2 months ago)
- Topics: docker, docker-image, google-puppeteer, puppeteer, screenshot
- Language: JavaScript
- Homepage: https://hub.docker.com/r/alekzonder/puppeteer/
- Size: 22.5 KB
- Stars: 485
- Watchers: 5
- Forks: 138
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-puppeteer - puppeteer docker image
- awesome-starred - alekzonder/docker-puppeteer - docker image with Google Puppeteer installed (docker)
- awesome-puppeteer - docker-puppeteer - Docker image with puppeteer installed. (Packages)
- awesome-puppeteer-zh - docker-puppeteer - 安装了puppeteer的Docker镜像. (包 / 贡献)
README
# puppeteer docker image
docker image with [Google Puppeteer](https://github.com/GoogleChrome/puppeteer) installed
and [screenshots scripts](#screenshots-tools)
[![nodesource/node](http://dockeri.co/image/alekzonder/puppeteer)](https://hub.docker.com/r/alekzonder/puppeteer/)
## docker tags
- `latest`
- `1`
- `1.1.1`
- `1.1.0`
- `1.0.0`
- `0`
- `0.13.0`
- `0.12.0`
- `0.11.0`
- `0.10.2`
- `0.10.1`
- `0.10.0`
- `0.9.0`## install
```
docker pull alekzonder/puppeteer:latest
# OR
docker pull alekzonder/puppeteer:1.0.0
# OR
docker pull alekzonder/puppeteer:1```
## before usage
1. you should pass `--no-sandbox, --disable-setuid-sandbox` args when launch browser
```js
const puppeteer = require('puppeteer');(async() => {
const browser = await puppeteer.launch({
args: [
'--no-sandbox',
'--disable-setuid-sandbox'
]
});const page = await browser.newPage();
await page.goto('https://www.google.com/', {waitUntil: 'networkidle2'});
browser.close();
})();
```2. if you got page crash with `BUS_ADRERR` ([chromium issue](https://bugs.chromium.org/p/chromium/issues/detail?id=571394)), increase shm-size on docker run with `--shm-size` argument
```bash
docker run --shm-size 1G --rm -v :/app/index.js alekzonder/puppeteer:latest
```3. If you're seeing random navigation errors (unreachable url) it's likely due to ipv6 being enabled in docker. Navigation errors are caused by ERR_NETWORK_CHANGED (-21) in chromium. Disable ipv6 in your container using `--sysctl net.ipv6.conf.all.disable_ipv6=1` to fix:
```bash
docker run --shm-size 1G --sysctl net.ipv6.conf.all.disable_ipv6=1 --rm -v :/app/index.js alekzonder/puppeteer:latest
```4. add `--enable-logging` for chrome debug logging http://www.chromium.org/for-testers/enable-logging
```js
const puppeteer = require('puppeteer');(async() => {
const browser = await puppeteer.launch({args: [
'--no-sandbox',
'--disable-setuid-sandbox',// debug logging
'--enable-logging', '--v=1'
]});```
## usage
### mount your script to /app/index.js
```bash
docker run --shm-size 1G --rm -v :/app/index.js alekzonder/puppeteer:latest
```### custom script from dir
```bash
docker run --shm-size 1G --rm \
-v :/app \
alekzonder/puppeteer:latest \
node my_script.js
```## screenshots tools
simple screenshot tools in image
```bash
docker run --shm-size 1G --rm -v /tmp/screenshots:/screenshots \
alekzonder/puppeteer:latest \
'https://www.google.com' 1366x768
```### screenshot tools syntax
` x []`
* `delay_in_ms`: is optional (defaults to `0`)
* Waits for `delay_in_ms` milliseconds before taking the screenshot### `screenshot`
```bash
docker run --shm-size 1G --rm -v /tmp/screenshots:/screenshots \
alekzonder/puppeteer:latest \
screenshot 'https://www.google.com' 1366x768
```output: one line json
```
{
"date":"2017-09-01T05:03:27.464Z",
"timestamp":1504242207,
"filename":"screenshot_1366_768.png",
"width":1366,
"height":768
}
```
got screenshot in /tmp/screenshots/screenshot_1366_768.png### `full_screenshot`
save full screenshot of page
```bash
docker run --shm-size 1G --rm -v /tmp/screenshots:/screenshots \
alekzonder/puppeteer:latest \
full_screenshot 'https://www.google.com' 1366x768
```### `screenshot_series`, `full_screenshot_series`
adds datetime in ISO format into filename
useful for cron screenshots
```bash
docker run --shm-size 1G --rm -v /tmp/screenshots:/screenshots \
alekzonder/puppeteer:latest \
screenshot_series 'https://www.google.com' 1366x768
``````bash
docker run --shm-size 1G --rm -v /tmp/screenshots:/screenshots \
alekzonder/puppeteer:latest \
full_screenshot_series 'https://www.google.com' 1366x768
``````
2017-09-01T05:08:55.027Z_screenshot_1366_768.png
# OR
2017-09-01T05:08:55.027Z_full_screenshot_1366_768.png
```