• Stars
    star
    1,392
  • Rank 33,756 (Top 0.7 %)
  • Language
    Dockerfile
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Chrome Headless docker images built upon alpine official image

GitHub Stars Docker Build Status Docker Pulls Docker Stars

All Contributors

Available registries

Following the changes with the Rate Limiting on Docker Hub. Tweet here for more information in ๐Ÿ‡ซ๐Ÿ‡ท

  • On the Docker Hub without any prefix: zenika/alpine-chrome
  • On Google Cloud - available in the closest region:
    • Global: gcr.io/zenika-hub/alpine-chrome
    • Europe: eu.gcr.io/zenika-hub/alpine-chrome
    • Asia: asia.gcr.io/zenika-hub/alpine-chrome
    • US: us.gcr.io/zenika-hub/alpine-chrome

Supported tags and respective Dockerfile links

  • latest, 100 (Dockerfile)
  • with-node, 100-with-node, 100-with-node-16 (Dockerfile)
  • with-puppeteer, 100-with-puppeteer (Dockerfile)
  • with-playwright, 100-with-playwright (Dockerfile)
  • with-selenoid, 100-with-selenoid (Dockerfile)
  • with-chromedriver, 100-with-chromedriver (Dockerfile)
  • 89, 86, 85, 84, 83, 81, 80, 77, 76, 73, 72, 71, 68, 64
  • 89-with-node, 86-with-node, 85-with-node, 84-with-node, 83-with-node, 81-with-node, 80-with-node, 77-with-node, 76-with-node
  • 89-with-puppeteer, 86-with-puppeteer, 85-with-puppeteer,84-with-puppeteer, 83-with-puppeteer, 81-with-puppeteer, 80-with-puppeteer, 77-with-puppeteer, 76-with-puppeteer

alpine-chrome

Chrome running in headless mode in a tiny Alpine image


๐Ÿค” Why use a Headless Chrome

In the world of webdev, the ability to run quickly end-to-end tests are important. Popular technologies like Puppeteer enable developers to make fun things like testing, automating forms, crawling, generating screenshots, capturing timeline... And there is a secret: some of these features are directly available on Chrome! ๐Ÿ™Œ

๐Ÿ’ก Crafting the perfect container

  • ๐Ÿ“ฆ Tiniest Headless Chrome (Compressed size: 423 MB)
  • ๐Ÿณ Easy to use, ephemeral and reproducible Headless Chrome with Docker
  • ๐Ÿ“ Doc-friendly with examples for printing the DOM, generating an image with a mobile ratio or generating a PDF.
  • ๐Ÿ‘ทโ€โ™‚๏ธ Autobuild with the Docker Hub to sync the project and ship the images with confidence
  • ๐Ÿ“Œ Up-to-date latest Chromium and tags available to test different versions of Chromium
  • ๐Ÿ” Secure with the best way to use Chrome and Docker - See "3 ways to securely use Chrome Headless" section
  • ๐ŸŒ Ready for internationalisation use: support for asian characters - See "screenshot-asia.js" file
  • ๐Ÿ’„ Ready for design use: support for WebGL, support for emojis- See "How to use with WebGL" section and "Emojis are not rendered properly" section
  • ๐Ÿ“„ Open Source with an Apache2 licence
  • ๐Ÿ‘ฅ Community-built with external contributors - See "โœจ Contributors" section
  • ๐Ÿ’š Dev-friendly with examples using NodeJS, Puppeteer, docker-compose and also a test with a X11 display - See "Run examples" section

3 ways to securely use Chrome Headless with this image

โŒ With nothing

Launching the container using only docker container run -it zenika/alpine-chrome ... will fail with some logs similar to #33.

Please use the 3 others ways to use Chrome Headless.

โœ… With --no-sandbox

Launch the container using:

docker container run -it --rm zenika/alpine-chrome and use the --no-sandbox flag for all your commands.

Be careful to know the website you're calling.

Explanation for the no-sandbox flag in a quick introduction here and for More in depth design document here

โœ… With SYS_ADMIN capability

Launch the container using: docker container run -it --rm --cap-add=SYS_ADMIN zenika/alpine-chrome

This allows to run Chrome with sandboxing but needs unnecessary privileges from a Docker point of view.

โœ… The best: With seccomp

Thanks to ever-awesome Jessie Frazelle seccomp profile for Chrome. This is The most secure way to run this Headless Chrome docker image.

chrome.json

Also available here wget https://raw.githubusercontent.com/jfrazelle/dotfiles/master/etc/docker/seccomp/chrome.json

Launch the container using: docker container run -it --rm --security-opt seccomp=$(pwd)/chrome.json zenika/alpine-chrome

How to use in command line

Default entrypoint

The default entrypoint runs chromium-browser --headless with some common flags from CHROMIUM_FLAGS set in the Dockerfile.

You can change the CHROMIUM_FLAGS by overriding the environment variable using: docker container run -it --rm --env CHROMIUM_FLAGS="--other-flag ..." zenika/alpine-chrome chromium-browser ...

You can get full control by overriding the entrypoint using: docker container run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser ...

Use the devtools

Command (with no-sandbox): docker container run -d -p 9222:9222 zenika/alpine-chrome --no-sandbox --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 https://www.chromestatus.com/

Open your browser to: http://localhost:9222 and then click on the tab you want to inspect. Replace the beginning https://chrome-devtools-frontend.appspot.com/serve_file/@.../inspector.html?ws=localhost:9222/[END] by chrome-devtools://devtools/bundled/inspector.html?ws=localhost:9222/[END]

Print the DOM

Command (with no-sandbox): docker container run -it --rm zenika/alpine-chrome --no-sandbox --dump-dom https://www.chromestatus.com/

Print a PDF

Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --print-to-pdf --hide-scrollbars https://www.chromestatus.com/

Take a screenshot

Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars https://www.chromestatus.com/

Size of a standard letterhead.

Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars --window-size=1280,1696 https://www.chromestatus.com/

Nexus 5x

Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars --window-size=412,732 https://www.chromestatus.com/

Screenshot owned by current user (by default the file is owned by the container user)

Command (with no-sandbox): docker container run -u `id -u $USER` -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars --window-size=412,732 https://www.chromestatus.com/

How to use with Deno

Go the deno src folder. Build your image using this command:

docker image build -t zenika/alpine-chrome:with-deno-sample .

Then launch the container:

docker container run -it --rm zenika/alpine-chrome:with-deno-sample
 Download https://deno.land/std/examples/welcome.ts
 Warning Implicitly using master branch https://deno.land/std/examples/welcome.ts
 Compile https://deno.land/std/examples/welcome.ts
 Welcome to Deno ๐Ÿฆ•

With your own file, use this command:

docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome:with-deno-sample run helloworld.ts
Compile file:///usr/src/app/helloworld.ts
Download https://deno.land/std/fmt/colors.ts
Warning Implicitly using master branch https://deno.land/std/fmt/colors.ts
Hello world!

How to use with Puppeteer

With tool like "Puppeteer", we can add a lot things with our Chrome Headless.

With some code in NodeJS, we can improve and make some tests.

See the "with-puppeteer" folder for more details. We have to follow the mapping of Chromium => Puppeteer described here.

If you have a NodeJS/Puppeteer script in your src folder named pdf.js, you can launch it using the following command:

docker container run -it --rm -v $(pwd)/src:/usr/src/app/src --cap-add=SYS_ADMIN zenika/alpine-chrome:with-puppeteer node src/pdf.js

With the "font-wqy-zenhei" library, you could also manipulate asian pages like in "screenshot-asia.js"

docker container run -it --rm -v $(pwd)/src:/usr/src/app/src --cap-add=SYS_ADMIN zenika/alpine-chrome:with-puppeteer node src/screenshot-asia.js

These websites are tested with the following supported languages:

  • Chinese (with https://m.baidu.com)
  • Japanese (with https://www.yahoo.co.jp/)
  • Korean (with https://www.naver.com/)

How to use with Puppeteer to test a Chrome Extension

According to puppeteer official doc you can not test a Chrome Extension in headleass mode. You need a display available, that's where Xvfb comes in.

See the "with-puppeteer-xvfb" folder for more details. We have to follow the mapping of Chromium => Puppeteer described here.

Assuming you have a NodeJS/Puppeteer script in your src folder named extension.js, and the unpacked extension in the chrome-extension folder, you can launch it using the following command:

docker container run -it --rm -v $(pwd)/src:/usr/src/app/src --cap-add=SYS_ADMIN zenika/alpine-chrome:with-puppeteer-xvfb node src/extension.js

The extension provided will change the page background in red for every website visited. This demo will load the extension and take a screenshot of the icanhazip.com website.

How to use with Playwright

Like "Puppeteer", we can do a lot things using "Playwright" with our Chrome Headless.

Go to the with-playwright folder and launch the following command:

docker container run -it --rm -v $(pwd)/src:/usr/src/app/src --cap-add=SYS_ADMIN zenika/alpine-chrome:with-playwright node src/useragent.js

A example-chromium.png file will be created in your with-playwright/src folder.

How to use with WebGL

By default, this image works with WebGL.

If you want to disable it, make sure to add --disable-gpu when launching Chromium.

docker container run -it --rm --cap-add=SYS_ADMIN -v $(pwd):/usr/src/app zenika/alpine-chrome --screenshot --hide-scrollbars https://webglfundamentals.org/webgl/webgl-fundamentals.html

docker container run -it --rm --cap-add=SYS_ADMIN -v $(pwd):/usr/src/app zenika/alpine-chrome --screenshot --hide-scrollbars https://browserleaks.com/webgl

How to use with Chromedriver

ChromeDriver is a separate executable that Selenium WebDriver uses to control Chrome. You can use this image as a base for your Docker based selenium tests. See Guide for running Selenium tests using Chromedriver.

How to use with Selenoid

Selenoid is a powerful implementation of Selenium hub using Docker containers to launch browsers. Even if it used to run browsers in docker containers, it can be quite useful as lightweight Selenium replacement. with-selenoid image is a self sufficient selenium server, chrome and chromedriver installed.

You can run it with following command:

docker container run -it --rm --cap-add=SYS_ADMIN  -p 4444:4444 zenika/alpine-chrome:with-selenoid -capture-driver-logs

And run your tests against http://localhost:4444/wd/hub

One of the use-cases might be running automation tests in the environment with restricted Docker environment like on some CI systems like GitLab CI, etc. In such case you may not have permissions for --cap-add=SYS_ADMIN and you will need to pass the --no-sandbox to chromedriver.

See more selenoid docs

Run as root and override default entrypoint

We can run the container as root with this command:

docker container run --rm -it --entrypoint "" --user root zenika/alpine-chrome sh

Run examples

Some examples are available on the examples directory:

  • ๐Ÿณ docker-compose to launch a chrome calling a nginx server in the same docker-compose
  • โ˜ธ๏ธ kubernetes to launch a pod with a headless chrome
  • ๐Ÿ–ฅ x11 to experiment this image with a X11 server.

References

Versions (in latest)

Alpine version

docker container run -it --rm --entrypoint "" zenika/alpine-chrome cat /etc/alpine-release
3.15.4

Chrome version

docker container run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser --version
Chromium 100.0.4896.60

Image disk size

docker image inspect zenika/alpine-chrome --format='{{.Size}}'
357467827 # 341 MB

โœจ Contributors

Thanks goes to these wonderful people (emoji key):


Julien Landurรฉ

๐Ÿ’ป ๐Ÿ‘€ โš ๏ธ ๐Ÿค” ๐Ÿ’ฌ ๐Ÿšง

Yonggang Luo

๐Ÿ’ป ๐Ÿค” ๐Ÿ’ฌ

Dennis Koch

๐Ÿ’ป ๐Ÿค” ๐Ÿ’ฌ

Sargon Piraev

๐Ÿ’ป

Eric Briand

๐Ÿ’ป

ๆ ฉ้ฃŽ

๐Ÿ’ป ๐Ÿค”

Roman Pushkin

๐Ÿ’ป

Juan Lladรณ

๐Ÿ’ป

Chris Watson

๐Ÿ›

Wang Guan

๐Ÿ›

ร“scar Soto Sรกnchez

๐Ÿ›

Calinoiu Alexandru Nicolae

๐Ÿ›

Mark Macdonald

๐Ÿ›

Felix Mann

๐Ÿ›

horacimacias

๐Ÿ›

Emil Kjer

๐Ÿ›

Jeff Gonzalez

๐Ÿ›

George Gaรกl

๐Ÿ›

wheestermans31

๐Ÿ›

Hodossy, Szabolcs

๐Ÿ›

Corentin Ardeois

๐Ÿ›

Danny Althoff

๐Ÿ’ฌ

Chad Wilson

๐Ÿ’ฌ ๐Ÿค”

fenchu

๐Ÿ›

nrawat151290

๐Ÿ›

x0rzkov

๐Ÿ› ๐Ÿค”

Jakob Ketterl

๐Ÿ›

Piotr Sikora

๐Ÿ› ๐Ÿค”

Pierre Grimaud

๐Ÿ’ป

Niek van der Maas

๐Ÿ’ฌ ๐Ÿค”

llange

๐Ÿ› ๐Ÿ’ป

Ageng D. Prastyawan

๐Ÿ“–

Neel Kamath

๐Ÿ’ฌ

Peter Dave Hello

๐Ÿ’ป

Taras

๐Ÿ’ป ๐Ÿ“–

Antoine Oili

๐Ÿ“–

Manuel Cepeda

๐Ÿ’ป

Simon Frey

๐Ÿ’ป

Santhosh C

๐Ÿ“–

This project follows the all-contributors specification. Contributions of any kind welcome!

๐ŸŽ‰ Show your support

โญ๏ธ this repo or leave a comment here

๐Ÿ’š Support this repository using GitHub Sponsor

More Repositories

1

grenoble-hands-on-front-clean-architecture

Attempt to clean architecture in frontend application & comparison between angular / react / vuejs
TypeScript
87
star
2

karto

A simple static analysis tool to explore a Kubernetes cluster : observe your cluster state in real time, diagnosticate network policies, and more!
JavaScript
46
star
3

angular-from-scratch

JavaScript
37
star
4

k8s-on-gce

Use Infra as Code to pop a k8S cluster on gcp
Shell
33
star
5

docker-kotlin

Kotlin docker images built upon official openjdk images.
Go
30
star
6

pagiel

PAGIEL est un outil de monitoring d'indicateurs environnementaux d'un projet web, fait pour รชtre intรฉgrรฉ dans des pipelines de dรฉploiement continu.
Python
29
star
7

zenika-career-paths-framework

Zenika Career Paths framework to help our collaborators customize their sought goals to develop their impact in the IT industry.
28
star
8

adoc-presentation-model

A full AsciiDoc extended example generating both HTML PDF and Reveal.js slides #asciidoctor #plantuml #reveal
Shell
27
star
9

traefik-gke-demo

Demo to use Traefik as GKE loadbalancer
HTML
26
star
10

alpine-firestore-backup

Image that performs Firestore backups based on Alpine Google Cloud SDK image.
Shell
25
star
11

zenscaler

A flexible autoscaler for docker
Go
19
star
12

Blogs

Source code for the blog posts
Java
19
star
13

kubernetes-security-workshop

Ruby
19
star
14

alpine-maven

Minimal Java/Maven Docker Images built on Alpine Linux
Dockerfile
17
star
15

java-snapshot-matcher

Snapshot testing with Java
Java
17
star
16

sensei

The compiler for our training material.
JavaScript
16
star
17

labs-tooling

Opensource tooling used at Zenika Labs
Dockerfile
12
star
18

trainingclazz-k8s

Shell
11
star
19

talk-continuous-delivery-tools

Shell
11
star
20

alpine-node

Minimal Node.js Docker Images built on Alpine Linux
Dockerfile
11
star
21

goru

Goru - the perfect looser to transform your pdf
Go
11
star
22

alpine-kotlin

Kotlin docker images built upon official openjdk alpine images.
11
star
23

feedzback

Request and give feedback to your colleagues
TypeScript
10
star
24

humeur-du-mois

An app that asks Zenika employees how they feel
TypeScript
8
star
25

react-workbench

Design your React component in an isolated context
JavaScript
8
star
26

coffee-button

Too busy to make a phone call, now we just push a button
C++
8
star
27

ids-ksql

Demo project for (Intrusion Detection System) IDS with KSQL and Kafka
Java
8
star
28

findbugs-tainted-mode

FindBugs with tainted mode patches
Java
7
star
29

wicket-component-debug

JavaScript
6
star
30

github-insights

GitHub Insights for organization
JavaScript
6
star
31

Try

Java
6
star
32

skillZ

App to manage consultants' skills and technical appetites.
TypeScript
6
star
33

gcloud-certbot

Cloud Run service for automatic renewal of wildcard SSL certificates for App Engine apps.
Shell
6
star
34

hoc-react-datgui

HOC adding dat.GUI plugged to React.Component props.
JavaScript
5
star
35

workshop-redis

Learn about how works redis in master/replica and cluster mode.
Shell
5
star
36

nc-kubernetes-dev-tools

Nightclazz Kubernetes - CI/CD tools
Shell
5
star
37

lunchPlace

LunchPlace est une application des gestion et de proposition de points de restauration entre collรจgues.
Kotlin
5
star
38

ateliers-devoxx

Des exercices simples sur des techno ร  la mode pour le stand Zenika ร  Devoxx
Java
5
star
39

kbooks

Kotlin / Spring 5 application that manages books
Kotlin
5
star
40

est-ce-que-lascenseur-de-nantes-est-utilisable

HTML
5
star
41

links.zenika.com

Create Zenika-branded links that redirect to anywhere!
JavaScript
4
star
42

refactoringame

4
star
43

talend-neo4j-connector

4
star
44

MarZ

La recette des Mar'Z
4
star
45

visual-migration-testing

Python
4
star
46

nc-terraform-101

Nightclazz Terraform 0.13
HCL
4
star
47

alpine-appengine-java

AppEngine Java Docker Images built on Google CloudSDK Alpine Linux plus jdk8 and maven
Dockerfile
4
star
48

cours-services-web-avec-nodejs

JavaScript
4
star
49

alpine-jenkins-with-docker

Minimal Jenkins Docker Images built on Alpine Linux
Dockerfile
4
star
50

talend-tNeo4jOuput-UI

Interface for tNeo4jOutput component
Java
3
star
51

grenoble-hands-on-angular

TypeScript
3
star
52

devfest-mcbomb

C++
3
star
53

ziem-graphanalysis

Cypher
3
star
54

zenboard

JavaScript
3
star
55

nantes-workadventure

HTML
3
star
56

varnishtest-exec

Java
3
star
57

scan-and-give

Scan your QR code and make a donation
JavaScript
3
star
58

lille-dojo

Kotlin
3
star
59

nc-kafka-fundamentals

Java
3
star
60

github-archiver

A tool to backup unused private GitHub repos to Google Drive, then delete them.
TypeScript
3
star
61

nc-angularjs-decouverte

NightClazz AngularJS Dรฉcouverte
Java
3
star
62

grao

An app that crawls our Dropbox and indexes documents to make them easily searchable
Vue
3
star
63

nc-kotlin-server

TypeScript
3
star
64

wicket-validation

Wicket JSR-303 (Bean Validation)
Java
3
star
65

express-mockups-middleware

Serve mockups on proxified requests
JavaScript
3
star
66

Presentations

Materials for public demos, conferences
Groff
3
star
67

grenoble-hands-on-front-angular-mocks-backend

TypeScript
2
star
68

kops-toolbox

Shell
2
star
69

qvgdc-app

Qui veut gagner des canards ?
JavaScript
2
star
70

bestoftz-workadventure

HTML
2
star
71

Alexandrie

Kotlin
2
star
72

nc-kubernetes

Shell
2
star
73

react-isomorphic-loader

An higher order component to load frontend libraries only in browser for react isomorphic apps
JavaScript
2
star
74

nightclazz_lagom

JavaScript
2
star
75

nc-spring-reactor

Java
2
star
76

singapore-nightclass-react

A step by step guide to build a e-commerce application from scratch
TypeScript
2
star
77

Zenika-bot

Python
2
star
78

grenoble-hands-on-vuejs

Simple weather app
Vue
2
star
79

firebase-web-101

Codelab Firebase 101 for web app
JavaScript
2
star
80

summerclazz-cloud

HTML
2
star
81

RabbitMQ-Management

Administration tools for RabbitMQ in java
Java
2
star
82

kafka-monitoring

A tool to monitor every aspects of kafka, kafka clients and kafka products.
Shell
2
star
83

strigo-init-script-libs

Script snippets for Strigo init scripts
Shell
2
star
84

hoc-react-switcher

SwitcherComponent
JavaScript
2
star
85

quizz-boxes

TodoMVC like about a quizz application with all implems imagined by the Web community of Zenika
CSS
2
star
86

TIL

Vue
2
star
87

Democratie_Liquide_Front

Democratie Liquide
Vue
2
star
88

nc-graphql-2019

Repository for TPs of the NightClazz on GraphQL at Bordeaux (04/12/19)
JavaScript
2
star
89

jarvis

JavaScript
2
star
90

codelab-iot

Codelab esp8266
Ruby
2
star
91

deadoralive

Quizz where you guess which rockstar is dead or alive.
HTML
2
star
92

lilaobot

A bot used to grab calls for offers from our customers and make them visible in slack channels
JavaScript
2
star
93

jms2amqp

PoC of a bidirectional bridge from JMS to AMQP
Java
2
star
94

NC-Docker-Avance

Nightclazz Docker avancรฉ
Shell
2
star
95

labs-svelte

Devenir Svelte avec Svelte, code labs pour dรฉcouvrir le framework javascript Svelte.
JavaScript
2
star
96

clever-hasura

Dockerfile for our hasura instance on clever
Dockerfile
1
star
97

talk-continuous-delivery-app

Java
1
star
98

remindit

JavaScript
1
star
99

workshop-spring-mvc-rest

Java
1
star
100

tsed-prisma-example

A Ts.ED project example with Prisma. Repo for the article published on Zenika blog
TypeScript
1
star