Giter VIP home page Giter VIP logo

docker-headless-shell's Introduction

About headless-shell

The headless-shell project provides a Docker image, chromedp/headless-shell, containing a pre-built version of Chrome's headless-shell -- a slimmed down version of Chrome that is useful for driving, profiling, or testing web pages.

Notably, this Docker image has been created expressly for the Go chromedp package, which provides a simple and easy to use API for driving browsers compatible with the Chrome Debugging Protocol.

The version of headless-shell contained in this Docker image has been modified from the original Chromium source tree, to report the same user agent as Chrome, and has had other minor modifications made to it in order make it better suited for use in an embedded context.

Running

You can use this Docker image in the usual way:

# pull latest version of headless-shell
$ docker pull chromedp/headless-shell:latest

# pull specific tagged version of headless-shell
$ docker pull chromedp/headless-shell:74.0.3717.1

# run
$ docker run -d -p 9222:9222 --rm --name headless-shell chromedp/headless-shell

# if headless-shell is crashing with a BUS_ADRERR error, pass a larger shm-size:
$ docker run -d -p 9222:9222 --rm --name headless-shell --shm-size 2G chromedp/headless-shell

# run as unprivileged user
# get seccomp profile from https://raw.githubusercontent.com/jfrazelle/dotfiles/master/etc/docker/seccomp/chrome.json
$ docker run -d -p 9222:9222 --user nobody --security-opt seccomp=chrome.json --entrypoint '/headless-shell/headless-shell' chromedp/headless-shell --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 --disable-gpu --headless

Using as a base image

When using chromedp/headless-shell as a base image to build an image that runs your own program, You could experience zombie process problem. To reap zombie processeses, use dumb-init or tini on your Dockerfile's ENTRYPOINT

FROM chromedp/headless-shell:latest
...
# Install dumb-init or tini
RUN apt install dumb-init
# or RUN apt install tini
...
ENTRYPOINT ["dumb-init", "--"]
# or ENTRYPOINT ["tini", "--"]
CMD ["/path/to/your/program"]

If running Docker 1.13.0 or later, use docker run's --init arg instead to reap zombie processes.

docker run -d -p <PORT>:<PORT> --name <your-program> --init <your-image>

Building and Packaging

The following contains instructions for building and packaging the chromedp/headless-shell Docker image manually.

Setup and Building

If you'd like to build this image yourself, locally, you will need to build headless-shell manually from the Chromium source. As such you will need to setup Chromium's depot_tools, your build environment, and a full checkout of the Chromium source tree and its related dependencies.

Please see the following for instructions on building Chromium and headless-shell on Linux:

Before proceeding, please ensure you have fully completed the above, have manually built headless-shell at least once, and that your Chromium source tree is up-to-date.

Building

After you are able to successfully build headless-shell directly from the Chromium source tree, you can simply run build-docker.sh:

# build headless-shell
$ ./build-headless-shell.sh /path/to/chromium/src 74.0.3717.1

# build docker image (uses $PWD/out/headless-shell-$VER.tar.bz2)
$ ./build-docker.sh 74.0.3717.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.