Using headless Chrome as an automated screenshot tool... in Docker!
This is a docker image that wraps headless Chrome, as well as
for cross platform relatively hi-fidelity screenshots of web pages.
This is not a lightweight method of taking a screenshot.
Building the docker image:
docker build -t tonious/chromeshot .
Using the docker image:
docker run --rm -it --security-opt seccomp=~/seccomp/chrome.json -v $(pwd):/output tonious/chromeshot --url="https://github.com/tonious/" --full --delay=3000 --output=/output/output.png
The output path of the screenshot is inside the docker container. If you would like that image to be saved outside of the container, you need to mount it as a volume.
Also, to run Chrome cleanly, you must either give the container
--cap-add=SYS_ADMIN (not good) or a valid seccomp profile (better).
Using the bash script.
chromeshot.sh hides some of the complexity of running the docker container:
- It passes in a seccomp configuration.
- It mounts the appropriate target directory into the vm.
usage: ./chromeshot.sh [ -d DELAY ] [ -o OUTFILE ] [ -x WIDTH ] [ -y HEIGHT ] URL Take a screenshot of a website using headless Chrome and docker.