Giter Club home page Giter Club logo

alpine-chrome's Introduction

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 GitHub Container registry: ghcr.io/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 with-puppeteer/test/screenshot-asia.js

docker container run -it --rm -v $(pwd)/with-puppeteer/test:/usr/src/app/test --cap-add=SYS_ADMIN zenika/alpine-chrome:with-puppeteer node test/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 headless 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 src/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 test test/test.js will load the extension and take a screenshot of the https://example.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)/test:/usr/src/app/test --cap-add=SYS_ADMIN zenika/alpine-chrome:with-playwright node test/test.js

An example.png file will be created in the with-playwright/test 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.19.1

Chrome version

docker container run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser --version
# Chromium 121.0.6167.85 Alpine Linux

Image disk size

docker image inspect zenika/alpine-chrome --format='{{.Size}}'
# 663644797 # 633 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

alpine-chrome's People

Contributors

agengdp avatar allcontributors[bot] avatar antoineoili avatar brunobastosg avatar chriscamicas avatar dependabot[bot] avatar ebriand avatar genewoo avatar hgwood avatar jcestibariz avatar jlandure avatar jllado avatar kikobeats avatar llange avatar mecm1993 avatar peterdavehello avatar pgrimaud avatar renovate[bot] avatar ro31337 avatar santhosh-chinnasamy avatar sargonpiraev avatar simonfrey avatar svenkirschbaum avatar taraspos avatar valegendre avatar zigarn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alpine-chrome's Issues

Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted

Please tell me what I'm doing wrong?

docker run -it  zenika/alpine-chrome

Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
[0908/094739.839947:FATAL:zygote_host_impl_linux.cc(187)] Check failed: ReceiveFixedMessage(fds[0], kZygoteBootMessage, sizeof(kZygoteBootMessage), &boot_pid). 
Received signal 6
  r8: 00000000000000c1  r9: 00007fa92f74114c r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffe84cf5630 r13: 0000000000000000 r14: 00007ffe84cf53e0 r15: 00000000000000a0
  di: 0000000000000002  si: 00007ffe84cf4d60  bp: 00007ffe84cf4d60  bx: 0000000000000006
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007fa92f6f75b7  sp: 00007ffe84cf4d48
  ip: 00007fa92f6f75b7 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.

When adding --no-sandbox - other errors appear

docker run -it  zenika/alpine-chrome --no-sandbox

[0908/101024.810903:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0908/101025.065766:ERROR:gpu_channel_manager.cc(398)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0908/101025.085427:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.

help me please!

Error on container launch: Failed to move to new namespace

I've tried to use it in my docker image based on zenika/alpine-chrome.
see dockerfile here: https://github.com/SuddenGunter/pandaren/tree/master/cmd

It didn't work for me, so I just try tried to do docker run zenika/alpine-chrome - same error.

Error message (happens in both cases)

Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
[0625/214704.494573:FATAL:zygote_host_impl_linux.cc(187)] Check failed: ReceiveFixedMessage(fds[0], kZygoteBootMessage, sizeof(kZygoteBootMessage), &boot_pid).
Received signal 6
  r8: 00000000000000c1  r9: 00007fb2bce9314c r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffec57e1860 r13: 00000000000000a0 r14: 000055c1b5d4ba64 r15: 00007ffec57e1880
  di: 0000000000000002  si: 00007ffec57e1730  bp: 00007ffec57e1730  bx: 0000000000000006
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007fb2bce49fa0  sp: 00007ffec57e1718
  ip: 00007fb2bce49fa0 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.

Environment:
macOS 10.14.5
docker v2.0.0.3 (31259), engine: 18.09.2

Β« Lost UI shared context Β» error

On OSX, I have this errors:

$ docker container run -it --rm --cap-add=SYS_ADMIN zenika/alpine-chrome                                                 stephane at MacBook-Pro-de-KLEIN.local (-)(master)
[0617/130836.688570:WARNING:dns_config_service_posix.cc(341)] Failed to read DnsConfig.
[0617/130836.693739:ERROR:gpu_process_transport_factory.cc(1009)] Lost UI shared context.
[0617/130836.698564:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[0617/130836.698614:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
[0617/130836.789673:ERROR:gl_implementation.cc(292)] Failed to load /usr/lib/chromium/swiftshader/libGLESv2.so: Error loading shared library /usr/lib/chromium/swiftshader/libGLESv2.so: No such file or directory
[0617/130836.794153:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[0617/130836.794245:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
[0617/130836.795285:ERROR:viz_main_impl.cc(196)] Exiting GPU process due to errors during initialization
[0617/130836.837893:ERROR:gl_implementation.cc(292)] Failed to load /usr/lib/chromium/swiftshader/libGLESv2.so: Error loading shared library /usr/lib/chromium/swiftshader/libGLESv2.so: No such file or directory
[0617/130836.840525:ERROR:viz_main_impl.cc(196)] Exiting GPU process due to errors during initialization
[0617/130836.840815:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[0617/130836.840888:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
[0617/130836.908523:ERROR:gl_implementation.cc(292)] Failed to load /usr/lib/chromium/swiftshader/libGLESv2.so: Error loading shared library /usr/lib/chromium/swiftshader/libGLESv2.so: No such file or directory
[0617/130836.914651:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[0617/130836.914733:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
[0617/130836.917125:ERROR:viz_main_impl.cc(196)] Exiting GPU process due to errors during initialization
[0617/130836.966942:ERROR:gl_implementation.cc(292)] Failed to load /usr/lib/chromium/swiftshader/libGLESv2.so: Error loading shared library /usr/lib/chromium/swiftshader/libGLESv2.so: No such file or directory
[0617/130836.968933:ERROR:viz_main_impl.cc(196)] Exiting GPU process due to errors during initialization
[0617/130836.969294:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[0617/130836.969336:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
[0617/130836.970184:ERROR:service_manager_context.cc(219)] Attempting to run unsupported native service: /usr/lib/chromium/content_gpu.service

Existing docker images based on alpine-chrome:with-puppeteer are now broken

Since this commit my build pipeline is broken.

My docker image did this in the final step:
CMD ["node", "run"]

And it seems that having tini set as the entrypoint breaks this behaviour.

Of course I can fix this in my Dockerfile but this won't fix old revisions of images that are based off of alpine-chrome:with-puppeteer. Was it a conscious decision to break existing behaviour?

\"tini\": executable file not found in $PATH

After adding ENTRYPOINT ["tini", "--"] it breaks the Puppeteer Docker image.

Reference commit:
7b4f2b3#diff-c29f529b3e98482e07a5768ff85c139dR9

Reproduce by:

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

docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"tini\": executable file not found in $PATH": unknown.
ERRO[0001] error waiting for container: context canceled

Permissions on mounted files

From an email

How to read the image generated after the screenshot?
The image is created into the mapped directory (to the volume) but the owner of the image is 1001 (root outside the container?):
-rw------- 1 1001 1001 2454 mar 8 16:48 screenshot.png

So I can't open the image until I've changed the permissions.

Any idea how to solve it?

`apk update` fails

I'm extending the Chrome v72 image. This is my Dockerfile:

$ cat Dockerfile
FROM zenika/alpine-chrome:72
USER root
RUN apk update

When I build it, the apk command fails.

$ docker build --no-cache --rm -f Dockerfile .
Sending build context to Docker daemon  3.072kB
Step 1/3 : FROM zenika/alpine-chrome:72
 ---> 361552ddc6fb
Step 2/3 : USER root
 ---> Running in b7440d6d4cdb
Removing intermediate container b7440d6d4cdb
 ---> d906a9c502cf
Step 3/3 : RUN apk update
 ---> Running in 77125b8983dd
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.9/main: Bad file descriptor
WARNING: Ignoring APKINDEX.b89edf6e.tar.gz: Bad file descriptor
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.9/community: Bad file descriptor
WARNING: Ignoring APKINDEX.737f7e01.tar.gz: Bad file descriptor
fetch http://nl.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
ERROR: http://nl.alpinelinux.org/alpine/edge/community: Bad file descriptor
WARNING: Ignoring APKINDEX.49e1404d.tar.gz: Bad file descriptor
ERROR: http://nl.alpinelinux.org/alpine/edge/main: Bad file descriptor
WARNING: Ignoring APKINDEX.1ebd6aac.tar.gz: Bad file descriptor
4 errors; 115 distinct packages available
The command '/bin/sh -c apk update' returned a non-zero code: 4

Chromium package in v3.10 has upgraded to 77.x.x.x

We are using puppeteer 1.12.0 in our project. For this version, we need chromium 73.x.x.x which was present in v3.10 branch. Recently version has been upgraded to 77.x.x.x, which broke our application. can you pls mention the branch which has chromium 73.x.x.x package?

Cannot install stable alpine packages in :latest

Describe the bug
We are currently unable to build our cucumber test images since 3227d27 overwrites the alpine 3.10 repositories from the build, leaving only edge behind. While this may be necessary (not sure if it is) for the installation of chromium, I think it would be good practice to restore the original configuration afterwards.

There's also some feedback on the commit, requesting to open a ticket. I couldn't find one, so here it is.

To Reproduce
Steps to reproduce the behavior:

  1. zenika/alpine-chrome@sha256:e436385b09839d8f6cd69f3a13a5decd74ea7e2e64a832129c27dc2ac9e64e71
  2. Build custom image based on FROM zenika/alpine-chrome:latest
  3. Attempt to install packages, e.g. RUN apk add bash
Step 3/10 : RUN apk add bash
 ---> Running in 5b44d631b561
fetch http://nl.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  readline-8.0.1-r0:
    masked in: @edge
    satisfies: bash-5.0.11-r0[so:libreadline.so.8]
  bash-5.0.11-r0:
    masked in: @edge
    satisfies: world[bash]
The command '/bin/sh -c apk add bash' returned a non-zero code: 2

Fails due to the unavailability of apk "normal" repositories; Only bash@edge would be supported.

What is the expected behavior?
We'd like to be able to install packages from stable alpine again, without being forced to use (potentially unstable) edge versions.

What is the actual behavior?
See error above

Possible solution
Ideas:

  • refrain from using edge altogether
  • branch out a separate line of edge-images for those who need it
  • restore stable alpine repositories after edge is no longer necessary

Versions

Software Version(s)
Chromium Chromium 77.0.3865.75
Image zenika/alpine-chrome@sha256:e436385b09839d8f6cd69f3a13a5decd74ea7e2e64a832129c27dc2ac9e64e71
Docker Engine 18.018.09

Additional Context
Since this also affects :77, this leaves us completely unable to use the image altogether. Alpine has removed older versions of the chromedriver from their 3.10 repositories, leaving version 77 as only option. That, in turns, only supports chromium 77 and above, which means the :76 tag will not work for us, either.

Add a new way to get the swiftshader libs

Context

Thanks to @pxlrbt we have the so libs compiled and available for swiftshader (see #50)

Alternatives

Can you achieve the same result doing that?

It could be interesting to get or generate the libs without rebuilding Chrome (1,5 day), getting the generated APK, unpacking it and retrieving the so files.

RUN apk add --no-cache mesa-egl mesa-gles \
	&& rm -rf /var/lib/apt/lists/* \
    /var/cache/apk/* \
    /usr/share/man \
    /tmp/* \
    && mkdir /usr/lib/chromium/swiftshader/ \
    && cp /usr/lib/libGLESv2.so.2 /usr/lib/chromium/swiftshader/libGLESv2.so \
    && cp /usr/lib/libEGL.so.1 /usr/lib/chromium/swiftshader/libEGL.so
#    && ln -s /usr/lib/libGLESv2.so.2 /usr/lib/chromium/swiftshader/libGLESv2.so \
#    && ln -s /usr/lib/libEGL.so.1 /usr/lib/chromium/swiftshader/libEGL.so
# COPY swiftshader/libEGL.so /usr/lib/chromium/swiftshader/libEGL.so
# COPY swiftshader/libGLESv2.so /usr/lib/chromium/swiftshader/libGLESv2.so
RUN chmod 755 /usr/lib/chromium/swiftshader/libEGL.so
RUN chmod 755 /usr/lib/chromium/swiftshader/libGLESv2.so

It is not working... 😒

** Other alternative **

See @lygstate info
#50 (comment)

What do you think?

chromium-browser not starting

Describe the bug
First I want to thank you for this image, which is really helpful for our build system.
However, since today it seems like chromium fails to start with, displaying the following error:

Error relocating /usr/lib/chromium/chrome: _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found

It looks like this happens since the last image was pushed (5 hours ago)

To Reproduce
Steps to reproduce the behavior:

  1. Execute docker container run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser --version
  2. See error
Error relocating /usr/lib/chromium/chrome: _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found
Error relocating /usr/lib/chromium/chrome: _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found
Error relocating /usr/lib/chromium/chrome: _ZNSt19_Sp_make_shared_tag5_S_eqERKSt9type_info: symbol not found

I was able to reproduce the issue on multiple machines (mac and linux)

What is the expected behavior?
Chromium should be able to start and display its version

What is the actual behavior?
Chromium crashes

Possible solutions
I don't know yet but I'll try to dig in see if I find something.
If anybody knows how to fix it right away that would be greatly appreciated.

Versions

Software Version(s) How-to
Chromium ? docker run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser --version
Image zenika/alpine-chrome@sha256:794b317131be727d5b7489e42f28d62f400d1aa7ffade0948f0fd7942e9d27c9 docker image inspect --format='{{index .RepoDigests 0}}' zenika/alpine-chrome
Docker Engine 19.03.2 docker version

chromium-browser segfaults :(

I can't get either of the latest zenika/alpine-chrome or zenika/alpine-chrome:with-node images to successfully launch a browser. If I expand one of the readme examples, this is what happens:

> docker run -it --rm --entrypoint sh zenika/alpine-chrome
> /usr/src/app $ chromium-browser --headless --disable-gpu --disable-software-rasterizer --disable-dev-shm-usage --no-sandbox --dump-dom https://www.chromestatus.com/
Segmentation fault

The only way I've got that example to work is by using the image tagged zenika/alpine-chrome:13.

Do you know what's going on?

Create a Documentation website

Context

What are you trying to do and how would you want to do it differently? Is it something you currently you cannot do? Is this related to an issue/problem?
Would like to clean the README and create a doc website for using this image.
There is too many sections in the README explaining the different usecases...

Perhaps a doc website using VuePress...

Use image for PDF generation

Context

One of our projects has created some debian image with node+chrome installed to be able to create PDFs.

But our standard for now of base images is alpine. Is you alpine-chrome image capable to do? I did a lot of reading about chrome and alpine, and came quickly to chromium installation. But the guy told me that chromium can't be used for the PDF generation, he needs the real chrome.

Regards
Walter

unable to run with-puppeteer example

thanks for the work; the image looks like exactly what I need.
However I'm having trouble executing the with-puppeteer example:

docker run -it --rm -v $(pwd)/src:/usr/src/app/src --cap-add=SYS_ADMIN zenika/alpine-chrome:with-puppeteer node src/pdf.js
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: "tini": executable file not found in $PATH": unknown.

I'm running in on docker for OSX, in case that matters.

I also tried building a modified image (basically commenting out the ENTRYPOINT with tini) and then I get this error instead:

[0408/191634.027504:ERROR:headless_shell.cc(559)] Open multiple tabs is only supported when remote debugging is enabled.

Any clues on how can I troubleshoot or fix this?

Add `web-gl` by default?

Context

The base alpine-chrome is 135 MB. The web-gl one is 138 MB.
Does it make sense to add it by default? πŸ€”

Discussion

Please help to decide πŸ‘

Publish image for arm

Hi, it would be awesome if you could publish images for ARM for running on Raspberry devices.

πŸ€” Remove tini

Describe the bug

From the tini lib

If you are using Docker 1.13 or greater, Tini is included in Docker itself. This includes all versions of Docker CE. To enable Tini, just pass the --init flag to docker run.

Chrome fails at startup with Jenkins agent

Describe the bug
I have a Jenkins with Kubernetes, and I would like to run a headless Chrome for unittesting (using Karma). I extended a Jenkins Agent image with alpine-chrome:with-node and use that in my agent pods. However karma is not able to start Chrome:

[0920/093525.387820:ERROR:zygote_host_impl_linux.cc(259)] Failed to adjust OOM score of renderer with pid 202: Permission denied (13)
[0920/093525.474421:ERROR:gpu_channel_manager.cc(398)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.

To Reproduce
Use this image:

FROM jenkins/jnlp-slave:alpine as jnlp

FROM alpine-chrome:with-node

USER root
RUN apk -U add openjdk8-jre

COPY --from=jnlp /usr/local/bin/jenkins-slave /usr/local/bin/jenkins-agent
COPY --from=jnlp /usr/share/jenkins/slave.jar /usr/share/jenkins/slave.jar

ENTRYPOINT ["/usr/local/bin/jenkins-agent"]

What is the expected behavior?
Karma able to start Chrome.

Logs

20 09 2019 09:35:24.438:INFO [launcher]: Starting browser Chrome

20 09 2019 09:35:32.813:ERROR [launcher]: Cannot start Chrome
[0920/093525.113146:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093525.387820:ERROR:zygote_host_impl_linux.cc(259)] Failed to adjust OOM score of renderer with pid 202: Permission denied (13)
[0920/093525.474421:ERROR:gpu_channel_manager.cc(398)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0920/093525.505667:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093532.787035:ERROR:browser_process_sub_thread.cc(203)] Waited 1 ms for network service

20 09 2019 09:35:32.813:ERROR [launcher]: Chrome stdout: 
20 09 2019 09:35:32.813:ERROR [launcher]: Chrome stderr: [0920/093525.113146:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093525.387820:ERROR:zygote_host_impl_linux.cc(259)] Failed to adjust OOM score of renderer with pid 202: Permission denied (13)
[0920/093525.474421:ERROR:gpu_channel_manager.cc(398)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0920/093525.505667:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093532.787035:ERROR:browser_process_sub_thread.cc(203)] Waited 1 ms for network service

20 09 2019 09:35:32.818:INFO [launcher]: Trying to start Chrome again (1/2).

20 09 2019 09:35:33.093:ERROR [launcher]: Cannot start Chrome
[0920/093532.949748:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093532.961242:ERROR:zygote_host_impl_linux.cc(259)] Failed to adjust OOM score of renderer with pid 248: Permission denied (13)
[0920/093533.004353:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093533.005844:ERROR:gpu_channel_manager.cc(398)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0920/093533.076144:ERROR:browser_process_sub_thread.cc(203)] Waited 3 ms for network service

20 09 2019 09:35:33.093:ERROR [launcher]: Chrome stdout: 
20 09 2019 09:35:33.093:ERROR [launcher]: Chrome stderr: [0920/093532.949748:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093532.961242:ERROR:zygote_host_impl_linux.cc(259)] Failed to adjust OOM score of renderer with pid 248: Permission denied (13)
[0920/093533.004353:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093533.005844:ERROR:gpu_channel_manager.cc(398)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0920/093533.076144:ERROR:browser_process_sub_thread.cc(203)] Waited 3 ms for network service

20 09 2019 09:35:33.096:INFO [launcher]: Trying to start Chrome again (2/2).

20 09 2019 09:35:33.373:ERROR [launcher]: Cannot start Chrome
[0920/093533.231075:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093533.244953:ERROR:zygote_host_impl_linux.cc(259)] Failed to adjust OOM score of renderer with pid 290: Permission denied (13)
[0920/093533.289019:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093533.289656:ERROR:gpu_channel_manager.cc(398)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0920/093533.359067:ERROR:browser_process_sub_thread.cc(203)] Waited 3 ms for network service

20 09 2019 09:35:33.373:ERROR [launcher]: Chrome stdout: 
20 09 2019 09:35:33.373:ERROR [launcher]: Chrome stderr: [0920/093533.231075:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093533.244953:ERROR:zygote_host_impl_linux.cc(259)] Failed to adjust OOM score of renderer with pid 290: Permission denied (13)
[0920/093533.289019:WARNING:dns_config_service_posix.cc(340)] Failed to read DnsConfig.
[0920/093533.289656:ERROR:gpu_channel_manager.cc(398)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0920/093533.359067:ERROR:browser_process_sub_thread.cc(203)] Waited 3 ms for network service

20 09 2019 09:35:33.376:ERROR [launcher]: Chrome failed 2 times (cannot start). Giving up.

Versions

Software Version(s) How-to
Chromium 76.0.3809.132 docker run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser --version
Image a449df36 docker image inspect --format='{{index .RepoDigests 0}}' zenika/alpine-chrome
Docker Engine 19.03.2 docker version

Additional context
I start Chrome with the following flags:
--headless, --no-sandbox, --disable-gpu, --disable-software-rasterizer, --disable-dev-shm-usage, --disable-web-security

npm not found

Hi,

npm has not been found since the last update.

BR
Sebastian

Bug image with-puppeter

Hi, you have a bug in the docker image with-puppeter, if you don't add a path "/usr/src/app" in the command "npm install", you will recived a error message in the execution.

module.js:549
throw err;
^

Error: Cannot find module 'puppeteer'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/usr/src/app/pdf.js:1:81)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

Then, if you modify the command for "RUN npm install /usr/src/app" you will resolved the problem. Best regards.

propose: add tini to reape (possible) zombie process

When building a pptraas.com-like service, I had to write this in Dockerfile (and they add to layers 😞):

USER root
RUN apk add tini
USER chrome
ENTRYPOINT ['tini', '--']

I am guessing the need to reape zombie process is common, can we add tini (or dumb-init or alike) to base image?

Remove the `with-webgl` tag

Describe the bug
Since the base image got the support of webgl, the with-webgl tag doesn't mean anything now.

  • Update README.md
  • Remove the webgl folder
  • Update the build on the Docker Hub

Add a `squash` version of alpine-chrome:latest

Context

πŸ’‘ This is only an idea.
To get a smaller image, we could use the experimental features docker image build --squash.
But it's not working on the Docker Hub. See docker/hub-feedback#955

Alternatives

I can do it on my laptop and upload it.
Here is the difference: only ~5MB

docker image inspect zenika/alpine-chrome --format='{{.Size}}'
393543827
docker image inspect zenika/alpine-chrome:latest-squash --format='{{.Size}}'
388574396

Conclusion

Not very useful at the moment. πŸ˜…

Dockerfile cleanups do not minimize image size

Hey,

first of all - thank you for this repo. You helped me in solving quite an annoying issue.
Thank you!

Secondly, I've found in Dockerfile quite intriguing lines:

alpine-chrome/Dockerfile

Lines 22 to 31 in 2d0b861

# Minimize size
RUN apk del --purge --force linux-headers binutils-gold gnupg zlib-dev libc-utils
RUN rm -rf /var/lib/apt/lists/* \
/var/cache/apk/* \
/usr/share/man \
/tmp/* \
/usr/lib/node_modules/npm/man \
/usr/lib/node_modules/npm/doc \
/usr/lib/node_modules/npm/html \
/usr/lib/node_modules/npm/scripts

Just wanted to mention that this will not minimize image size.

Each command creates a layer. Each layer adds a size of appended changes. Running cleanup commands in a separate layer will append 0-byte changes. It won't affect overall image size

There're few ways to fix this:

  • build image with --squash option
  • append cleanup tasks to previous RUN
  • create a separate installation script, copy it to image and run. This will create only two layers of changes (COPY of script and RUN which will install&cleanup)

Cheers! :)

Cannot manage to reproduce to use `with-playwright`

Hello everybody !

I'm facing the following issue:

Describe the bug
I'm not able to reproduce the getting started instructions for Playwright

To Reproduce
Steps to reproduce the behavior:

  1. Version of the image :
$ docker image inspect --format='{{index .RepoDigests 0}}' zenika/alpine-chrome:with-playwright
zenika/alpine-chrome@sha256:c3a832060aa529bd0ca87bc60ff669015bcc5c8d5138c25b729aee5c2ae8cad6
  1. Execute :
docker container run -it --rm -v $(pwd):/usr/src/app --cap-add=SYS_ADMIN zenika/alpine-chrome:with-playwright npm start
  1. See error
> [email protected] start /usr/src/app
> node src/useragent

internal/modules/cjs/loader.js:969
  throw err;
  ^

Error: Cannot find module 'playwright-chromium'
Require stack:
- /usr/src/app/src/useragent.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/usr/src/app/src/useragent.js:1:22)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/src/app/src/useragent.js' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node src/useragent`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/chrome/.npm/_logs/2020-06-17T10_09_15_847Z-debug.log

What is the expected behavior?
As per the documentation:

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

What is the actual behavior?

The above output - no png file created.

Possible solution
(Not found yet)

Logs
Log file 2020-06-17T10_09_15_847Z-debug.log

Versions

Software Version(s) How-to
Chromium Chromium 83.0.4103.61 docker run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser --version
Image zenika/alpine-chrome@sha256:c3a832060aa529bd0ca87bc60ff669015bcc5c8d5138c25b729aee5c2ae8cad6 docker image inspect --format='{{index .RepoDigests 0}}' zenika/alpine-chrome
Docker Engine Client 19.03.11 docker version
Docker Engine Server 19.03.5 docker version
Docker Machine 0.16.2, build bd45ab1 docker-machine version
Darwin Kernel Version 19.3.0
MacOS version Catalina 10.15.3 (19D76)

Additional context
I also tried to replace require("playwright-chromium"); with require("playwright"); nothing better.
I found the following issue but it's not the same version so I'm not sure it's relevant.

chrome 77 on stable alpine

Hi
I'm having stability issues with chromium77 on alpine edge, (selenium freezes), I like to use alpine stable (v3.10). I also like to use chromium76, the only chromium I found in stable was chrome73.
I currently use ubuntu 18.04 but it is 1.5GB large, while the alpine edge is only 384MB.

Getting symbol not found error

Building the image on archlinux and running

chromium-browser --version

Will result in:

Error relocating /usr/lib/chromium/chrome: hb_font_funcs_set_glyph_h_advances_func: symbol not found

add with selenium/playwright

Hi guys,

Hope you are doing well !

It would be awesome to have alpine chrome with selenium.

Is it something possible to add ?

Cheers,
X

Text in screenshot is fuzzy

I am attempting to use Chrome to take some screenshots.

Here is a screenshot taken on Alpine docker container run -it --rm -v $(pwd):/usr/src/app --security-opt seccomp=$(pwd)/chrome.json zenika/alpine-chrome --screenshot --no-sandbox --hide-scrollbars --window-size=1200,630 https://github.com/Zenika/alpine-chrome
alpine-screenshot

and a screenshot taken on macOS chromium --headless --use-gl=swiftshader --disable-software-rasterizer --disable-dev-shm-usage --screenshot --no-sandbox --hide-scrollbars --window-size=1200,630 https://github.com/Zenika/alpine-chrome
macos-screenshot

You can see in the Alpine screenshot, that all of the text appears super pixelated.

Any ideas?

Note: The Alpine screenshot looks much fuzzier in macOS finder than it does in the GitHub upload.

Docker-compose

Hi There. I am trying to set it up to use with docker-compose. However when I try to activate it the container keeps restarting and the terminal gives me:

[0511/154746.370034:WARNING:dns_config_service_posix.cc(335)] Failed to read DnsConfig.
docker-compose is as follows:

version: '3'
services:
testservice
build: ./installer
container_name: testservice
restart: always
ports:
- 9222:9222

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.