docker-headless-shell is a free, open source data extraction & web scraping project written in Shell and released under MIT. It has 681 GitHub stars, 81 forks and 1 open issues, and was last pushed 39 hours ago. On this registry it ranks #151 of 163 tracked projects in Data Extraction & Web Scraping, with 5 head-to-head comparisons available. It gained 1 stars over the last 5 tracked days.

What is docker-headless-shell?

docker-headless-shell is a multi-arch container image of Chrome's headless-shell — a slimmed-down version of Chrome — that provides a ready-to-run browser for any client speaking the Chrome DevTools Protocol, and is aimed at teams doing browser automation, page profiling, or web testing from Go, or from any other language with a CDP-capable library.

What it is

The project publishes the image docker.io/chromedp/headless-shell, which packages Chrome's headless-shell: a reduced Chrome build intended for driving, profiling, or testing web pages. The binary inside the image is built from the original Chromium source tree with modifications, most notably that it reports the same user agent as Chrome, along with other minor changes made to suit use in an embedded context. The repository itself is a set of shell build scripts and container packaging, released under the MIT licence. It lives in the Docker and browser-automation corner of the ecosystem and was created for the Go chromedp package, which offers an API for driving browsers compatible with the Chrome Debugging Protocol.

The concrete problem it solves is the cost of producing that binary and keeping it packaged. Following Chromium's Linux build instructions and the headless README by hand is a long, tool-heavy exercise; this project runs that build nightly on an Arch Linux host and packages only the resulting binaries into the container image, so consumers pull an image instead of compiling Chromium. It likewise removes the need to write and maintain a Dockerfile around a self-built headless-shell, and it targets more than one architecture rather than a single platform.

Key capabilities

  • Publishes multi-arch images for Chrome's stable, beta, and dev channels, pushed daily, addressable through the floating tags stable, beta, and dev or through an exact version tag such as 123.0.6312.86.
  • Exposes the Chrome DevTools Protocol over port 9222, so the image can be driven by the Go chromedp package or by any other library or application that supports the protocol.
  • Ships a modified build that reports the same user agent as Chrome, with further minor modifications for embedded use.
  • Supports unprivileged operation through --user nobody combined with a seccomp profile (chrome.json) and an explicit entrypoint of /headless-shell/headless-shell carrying the flags --remote-debugging-address=0.0.0.0, --remote-debugging-port=9222, --disable-gpu, --enable-unsafe-swiftshader, and --headless.
  • Documents workarounds for two runtime failure modes: increasing shared memory with --shm-size 2G when the container crashes with a BUS_ADRERR error, and reaping zombie processes with --init or by installing dumb-init or tini as a Dockerfile ENTRYPOINT.
  • Works as a base image, so a derived image can start FROM docker.io/chromedp/headless-shell:latest and set its own CMD for the program that drives the browser.

Who uses it and how

  • Go teams using chromedp, the package this image was originally created for, point their automation at the container's debugging port rather than managing a browser install.
  • Projects with an existing CDP client in another language use it unchanged, since the image supports any library or application that speaks the protocol.
  • Test and profiling workflows start the container per job (podman run -d -p 9222:9222 --rm --name headless-shell docker.io/chromedp/headless-shell) and discard it afterwards, which suits ephemeral CI runners.
  • Security-conscious operators run it as an unprivileged user with a seccomp profile, which is why the README carries a full invocation for that case.
  • Teams that need extra tooling bake a derived image on top of the published one and add their own entrypoint.

Getting started

Pull and run the published image directly, for example podman pull docker.io/chromedp/headless-shell:latest followed by podman run -d -p 9222:9222 --rm --name headless-shell docker.io/chromedp/headless-shell, or pin a specific version tag in place of latest. The image is also available from Docker Hub at chromedp/headless-shell.

How it compares

No paid or hosted products are listed as being replaced here, and the facts name no directly comparable image, so the project stands alone in this registry as a prebuilt multi-arch headless-shell container. The one related name in the README, the Go chromedp package, is a client library that drives the browser rather than an alternative to the image.

When to use it — and when not to

A self-hoster needs only a container runtime, but should expect to manage runtime details the README calls out: shared-memory sizing, an init process to avoid zombies, and, for unprivileged operation, a seccomp profile. Rebuilding the image from source is a heavier proposition, requiring an Arch Linux host with a long package list (base-devel, git-lfs, go, buildah, podman, qemu-user-static, and others) installed via yay. Anyone who wants a managed browser service, or who is unwilling to tune container flags, should not pick this up; the documentation is a build and run guide rather than an API reference, and the image defaults to running as root unless the unprivileged invocation is used explicitly.

project readme (upstream, from github) — read inline

About headless-shell

The headless-shell project provides a multi-arch container image, docker.io/chromedp/headless-shell, containing Chrome's headless-shell -- a slimmed down version of Chrome that is useful for driving, profiling, or testing web pages.

This image has been created for the Go chromedp package, which provides a simple and easy to use API for driving browsers compatible with the Chrome Debugging Protocol, but can be used with library or application that supports the Chrome Debugging Protocol.

The version of headless-shell contained in the docker.io/chromedp/headless-shell 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 to make it better suited for use in an embedded context.

Tags and Versions

Multi-arch images for Chrome's stable, beta, and dev channels are pushed daily to the docker.io/chromedp/headless-shell repository.

The image can be used via the stable, beta, or dev floating tags, or via a specific version tag:

# pull latest stable
$ podman pull docker.io/chromedp/headless-shell:latest

# pull specific version
$ podman pull docker.io/chromedp/headless-shell:123.0.6312.86

# pull beta
$ podman pull docker.io/chromedp/headless-shell:beta

# pull dev
$ podman pull docker.io/chromedp/headless-shell:dev

Running

The headless-shell container can be used in the usual way:

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

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

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

Zombie processes

When using docker.io/chromedp/headless-shell (either directly or as a base image), you could experience zombie processes problem. To reap zombie processes, use podman run's --init arg:

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

If running Docker older than 1.13.0, use dumb-init or tini on your Dockerfile's ENTRYPOINT

FROM docker.io/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"]

Building

headless-shell is built nightly on an Arch Linux host by the scripts in this repository (see Chromium's Linux build instructions and the headless README). The build runs directly on the host, and only the resulting binaries are packaged into the container image.

Host packages

Install the following with yay -S:

$ yay -S --needed \
    base-devel git git-lfs python perl curl jq go bzip2 \
    aarch64-linux-gnu-binutils gperf \
    buildah podman qemu-user-static qemu-user-static-binfmt
  • git, git-lfs, python and perl are used by the scripts, gclient and the Chromium build. git-lfs is required: Chromium's third_party/litert contains Git LFS files, and gclient sync fails without it

  • base-devel provides the build tools used by the scripts and Chromium's build (binutils, bison, flex, patch, file, and so on). strip from binutils is used on the amd64 binary

  • curl, jq and bzip2 are used by the scripts to verify and package the build

  • aarch64-linux-gnu-binutils provides aarch64-linux-gnu-strip, used on the arm64 binary

  • gperf, along with bison and flex, is a build tool named in Chromium's build/install-build-deps.py. The remaining packages there are for packaging, tests and distro libraries, and are not needed, as Chromium's toolchain and sysroots are downloaded by gclient

  • buildah, podman, qemu-user-static and qemu-user-static-binfmt are used to build and push the multi-arch container images

  • go is needed to install verhist, which is not packaged:

    $ go install github.com/chromedp/verhist/cmd/verhist@latest
    

    and it must be on the PATH of the user running the build

Running the build

# enable lingering and the timers
$ sudo loginctl enable-linger $USER
$ ./install.sh
$ systemctl enable --now --user headless-shell.timer

# run a build by hand, see all options with --help
$ ./build.sh --help
$ ./build.sh --channel stable --target amd64

# follow a build
$ journalctl --user -fu headless-shell.service

Pushing requires a registry token in ~/.config/headless-shell/token.

Failure notifications

If a build fails, headless-shell.service starts headless-shell-failure.service (via OnFailure=), which runs notify.sh to post a message, with the tail of the build log, to a Discord channel. Create a webhook for the channel and store its URL in ~/.config/headless-shell/discord-webhook:

$ install -m 600 /dev/null ~/.config/headless-shell/discord-webhook
$ $EDITOR ~/.config/headless-shell/discord-webhook

# test the notification
$ ./notify.sh --unit headless-shell.service

Frequently asked questions

Is docker-headless-shell free to use?

docker-headless-shell is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does docker-headless-shell do?

Multi-arch container image of Chrome's headless-shell, for browser automation from any CDP client.

What is docker-headless-shell written in?

docker-headless-shell is primarily written in Shell. Its source is publicly available at https://github.com/chromedp/docker-headless-shell, and it has 681 GitHub stars.