This repository contains two docker builds.
This docker image contain the Linux Dev channel Chromium (https://www.chromium.org/getting-involved/dev-channel), with the required dependencies and the command line argument running headless mode provided.
Dockerfile is located in https://github.com/yukinying/chrome-headless-browser-docker/blob/master/Dockerfile.
Currently, this image is built in a machine that pushes the image in regular interval and push to dockerhub.
Credits to SeleniumHQ https://github.com/SeleniumHQ/docker-selenium. The Dockerfile and configuration are taken from their repository, with modification to use google-chrome-unstable and removing unnecessary dependencies.
To run the container with remote-debugging:
docker run -it --rm --name chrome --shm-size=1024m -p=127.0.0.1:9222:9222 --cap-add=SYS_ADMIN \
yukinying/chrome-headless-browser
To run the container with other options, e.g. --dump-dom
:
docker run -it --rm --name chrome --shm-size=1024m --cap-add=SYS_ADMIN \
--entrypoint=/usr/bin/google-chrome-unstable \
yukinying/chrome-headless-browser \
--headless --disable-gpu --dump-dom https://www.facebook.com
See the following sections for alternate ways to start the container.
Currently, there is a user namespace issue in OSX that generates this error:
Failed to move to new namespace: PID namespaces supported, Network namespace supported,
but failed: errno = Operation not permitted
There are two mitigations, but none of them are ideal as it gives the container some special capabilities:
- Use a special seccomp profile, as stated in https://twitter.com/jessfraz/status/681934414687801345
docker run -it --rm --name chrome --shm-size=1024m -p=127.0.0.1:9222:9222 --security-opt seccomp:/path/to/chrome.json \
yukinying/chrome-headless-browser
- Use CAP_SYS_ADMIN
docker run -it --rm --name chrome --shm-size=1024m -p=127.0.0.1:9222:9222 --name chrome --cap-add=SYS_ADMIN \
yukinying/chrome-headless-browser
Try adding the following flag: --enable-logging --v=10000
docker run -it --rm --name chrome --shm-size=1024m --cap-add=SYS_ADMIN \
-p=127.0.0.1:4444:4444 \
yukinying/chrome-headless-browser-selenium
If you would like to use headless_shell
instead of chrome --headless
in Docker, please check out https://github.com/yukinying/chrome-headless-travis-build