chromedp/docker-headless-shell

repository·main·Indexed 20 days ago

https://github.com/chromedp/docker-headless-shell

A multi-arch container image containing a slimmed-down version of Chrome's headless-shell. Optimized for driving, profiling, or testing web pages via the Chrome Debugging Protocol, specifically for use with the Go chromedp package. Provides images for stable, beta, and dev channels.

Tokens
926
Snippets
5
Records
5
Agent score
21%

What's inside chromedp-docker-headless-shell

  1. Run the headless-shell container

    main

    You can run the headless-shell container using standard container run commands. By default, it exposes port 9222 for the Chrome Debugging Protocol.

    # run
    $ podman run -d -p 9222:9222 --rm --name headless-shell docker.io/chromedp/headless-shell
  2. Run headless-shell as an unprivileged user

    main

    To run the container as an unprivileged user, you must provide a specific seccomp profile and override the entrypoint to pass the necessary Chrome flags.

    1. Download the required seccomp profile from: https://raw.githubusercontent.com/jfrazelle/dotfiles/master/etc/docker/seccomp/chrome.json
    2. Use the --user nobody and --security-opt seccomp=chrome.json flags.
    # run as unprivileged user
    $ 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
  3. Pull the headless-shell container image

    main

    The docker.io/chromedp/headless-shell repository provides multi-arch images for Chrome's stable, beta, and dev channels. You can pull the latest stable version, a specific version, or use the floating tags for beta or dev channels.

    # 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
  4. Prevent zombie processes in headless-shell

    main

    When using this image directly or as a base image, you may encounter zombie processes.

    If using Podman/Modern Docker: Use the --init flag in your run command to reap zombie processes.

    If using Docker older than 1.13.0: Install dumb-init or tini and set them as the ENTRYPOINT in your Dockerfile.

    # Use --init to reap zombie processes
    $ podman run -d -p <PORT>:<PORT> --name <your-program> --init <your-image>
    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"]
  5. Fix BUS_ADRERR crashes by increasing shm-size

    main

    If the headless-shell container crashes with a BUS_ADRERR error, it is likely due to insufficient shared memory. Resolve this by passing a larger --shm-size flag (e.g., 2G) during the run command.

    $ podman run -d -p 9222:9222 --rm --name headless-shell --shm-size 2G docker.io/chromedp/headless-shell