question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

docker alpine with node js and chromium headless - puppeter - failed to launch chrome

See original GitHub issue

I’m trying to run a custom node command from within an Alpine linux docker container.

Installed packages:

    alpine-baselayout
    alpine-keys
    libressl2.4-libcrypto
    libressl2.4-libssl
    apk-tools
    scanelf
    libc-utils
    glibc
    libgcc
    glibc-bin
    libbz2
    expat
    libffi
    gdbm
    xz-libs
    ncurses-terminfo-base
    ncurses-terminfo
    ncurses-libs
    readline
    sqlite-libs
    musl
    zlib
    libpng
    freetype
    pkgconf
    zlib-dev
    libpng-dev
    freetype-dev
    libstdc++
    binutils-libs
    binutils
    gmp
    isl
    libgomp
    libatomic
    mpfr3
    mpc1
    gcc
    musl-dev
    libc-dev
    g++
    ca-certificates
    libssh2
    libcurl
    pcre
    git
    libjpeg-turbo
    libjpeg-turbo-dev
    tiff
    tiff-dev
    lcms2
    lcms2-dev
    musl-utils
    libffi-dev
    libressl
    libressl2.4-libtls
    libressl-dev
    make
    db
    libsasl
    libldap
    libpq
    postgresql-libs
    postgresql-dev
    python2
    py-setuptools
    python3
    python3-dev
    libxau
    libbsd
    libxdmcp
    libxcb
    libx11
    gifsicle
    pngquant
    optipng
    libjpeg-turbo-utils
    busybox
    udev-init-scripts
    eudev-libs
    libuuid
    libblkid
    kmod
    eudev
    fontconfig
    libfontenc
    mkfontscale
    mkfontdir
    ttf-opensans
    libogg
    flac
    libxcomposite
    libxfixes
    libxrender
    libxcursor
    libxdamage
    libxext
    libxi
    libxrandr
    libxscrnsaver
    libxtst
    alsa-lib
    libintl
    libmount
    glib
    atk
    pixman
    cairo
    dbus-libs
    avahi-libs
    nettle
    libtasn1
    p11-kit
    libunistring
    gnutls
    cups-libs
    libxml2
    shared-mime-info
    hicolor-icon-theme
    gdk-pixbuf
    gtk-update-icon-cache
    libxinerama
    at-spi2-core
    at-spi2-atk
    cairo-gobject
    libepoxy
    graphite2
    harfbuzz
    libxft
    pango
    gtk+3.0
    minizip
    nspr
    nss
    snappy
    libwebp
    libgpg-error
    libgcrypt
    libxslt
    chromium
    .build-deps
    libwebp-dev
    c-ares
    libcrypto1.0
    http-parser
    libssl1.0
    libuv
    nodejs
    nodejs-npm
    libidl
    orbit2
    dbus-glib
    polkit
    gconf

node packages (npm list --depth=0):

    node-pdf-renderer@0.0.1 /var/www/my_proj/idf/static/js
    └── puppeteer@0.12.0

but I’m experiencing some errors:

    /var/www/my_proj/idf/static/js # node render.js uid=uid-param url=https://www.targethost.example token=tk-param out=/tmp/test.pdf
    
    (node:167) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Failed to launch chrome!
    /var/www/my_proj/idf/static/js/node_modules/puppeteer/.local-chromium/linux-508693/chrome-linux/chrome: /usr/lib/libasound.so.2: no version information available (required by /var/www/my_proj/idf/static/js/node_modules/puppeteer/.local-chromium/linux-508693/chrome-linux/chrome)
    
    
    TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
    
    (node:167) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

it seems that is not able to instantiate chromium. I also tried to modify teh render.js script while it creates an instance of the browser to this:

    const browser = await puppeteer.launch({
            args: ['--no-sandbox'],
            headless: false
        });

but I got the same result. Any help on this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

93reactions
ddehghancommented, Nov 15, 2018

This works too:

FROM node:10.7.0-alpine AS base
ENV CHROME_BIN="/usr/bin/chromium-browser" \
    PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
RUN set -x \
    && apk update \
    && apk upgrade \
    && apk add --no-cache \
    udev \
    ttf-freefont \
    chromium \
    && npm install puppeteer@1.10.0

          const browser = await puppeteer.launch({
                headless: true,
                executablePath: process.env.CHROME_BIN || null,
                args: ['--no-sandbox', '--headless', '--disable-gpu', '--disable-dev-shm-usage']
            });
23reactions
clayrissercommented, Jan 17, 2018

If you want to get puppeteer to work on alpine, try using an older version of puppeteer that works with an older version of Chrome. The newest version of Chrome supported on Alpine is 63, which was the version of Chrome used during the development of puppeteer version 0.11.0.

npm install --save puppeteer@0.11.0

This version of Chrome can only be found on Alpine edge. You can install it in older versions of Alpine by running the following.

ENV CHROME_BIN=/usr/bin/chromium-browser
RUN echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
    echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && \
    apk add --no-cache \
      chromium@edge \
      nss@edge

Make sure you start puppeteer the with the following configuration

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({
  executablePath: process.env.CHROME_BIN || null,
  args: ['--no-sandbox', '--headless', '--disable-gpu']
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

docker alpine with node js and chromium headless - puppeter
This worked for me. Use Puppeteer v0.13.0. As of writing this comment, the latest version of Puppeteer is not compatible with chromium in ......
Read more >
Puppeteer in alpine docker with chromium headless dosent ...
I'm trying to use pageres in my bash script for grabbing screenshot in heruko. But running pageres with alpine:latest throws error with ...
Read more >
How to use Puppeteer inside a Docker container
The easiest path to use Puppeteer inside a Docker container is installing Google Chrome because, in contrast to the Chromium package offered by ......
Read more >
Troubleshooting - Puppeteer
Chromium currently does not provide arm64 binaries for Linux. There are only binaries. ... Chrome is downloaded but fails to launch on Node.js...
Read more >
How to set up a Headless Chrome Node.js server in Docker
The run command handles the edge repository for getting Chromium for Linux and libraries required to run chrome for Alpine. The tricky part...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found