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.

Puppeteer in docker container: Chromium revision is not downloaded

See original GitHub issue

I’m trying to launch puppeteer in an express app that’s run in a docker container, using docker-compose.

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 0.13.0
  • Platform / OS version: jessie
  • Node.js version: 8.9.4

What steps will reproduce the problem?

Express app’s Dockerfile:

FROM node:8

RUN apt-get update

# for https
RUN apt-get install -yyq ca-certificates
# install libraries
RUN apt-get install -yyq libappindicator1 libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6
# tools
RUN apt-get install -yyq gconf-service lsb-release wget xdg-utils
# and fonts
RUN apt-get install -yyq fonts-liberation

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY code/package.json /usr/src/app
COPY code/index.js /usr/src/app
RUN mkdir -p /usr/src/app/views
COPY code/views/ /usr/src/app

# install the necessary packages
RUN yarn install

CMD npm run start:dev

docker-compose.yml:

app:
    restart: always
    build: ${REPO}
    volumes:
        - ${REPO}/code:/usr/src/app:ro
    working_dir: /usr/src/app
    ports:
        - "8087:5000"

index.js route:

app.post('/img', function (req, res) {
  const puppeteer = require('puppeteer');
  (async() => {
    const browser = await puppeteer.launch({args: ['--no-sandbox']});
  })();
});

What is the expected result? Puppeteer can launch a browser in the express app.

What happens instead?

The line that should launch puppeteer const browser = await puppeteer.launch({args: ['--no-sandbox']}); throws the following error:

(node:28) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): AssertionError [ERR_ASSERTION]: Chromium revision is not downloaded. Run "npm install"

I’ve tried adding a yarn add puppeteer after the yarn install in the Dockerfile. I’ve also tried replacing yarn install in the Dockerfile with npm install . Neither makes a difference.

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
wallaceprestoncommented, Jan 28, 2020

I don’t know where I found this solution (it was another GitHub issue). I am running node 12 alpine inside a docker container, and these 3 lines were necessary right before RUN npm install. This (1) Installs chromium so it’s available in the container, (2) tells puppeteer not to install chromium, and (3) tells puppeteer what path it can find chromium at.

RUN apk add -U --no-cache --allow-untrusted udev ttf-freefont chromium git
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV CHROMIUM_PATH /usr/bin/chromium-browser

Then when I use puppeteer in my JS code, I have to tell it what path to use (the ENV var I set above).

const puppeteer = require('puppeteer');

const browser = await puppeteer.launch({
	headless: true,
	executablePath: process.env.CHROMIUM_PATH,
	args: ['--no-sandbox'],
});

Note: I didn’t hardcode the path, since I want to use a different path per OS (I don’t always run my app in Docker)

4reactions
ebidelcommented, Jan 10, 2018

That path looks like it’s from a mac. If you’re in Docker, it should be something like ./node_modules/puppeteer/.local-chromium/linux-515411/.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer in docker container: Chromium revision is not ...
The docker volume I was using mapped the entire local code directory to the docker container's /usr/src/app directory.
Read more >
Node.js – Puppeteer in docker container: Chromium revision is not ...
I'm trying to launch puppeteer in an express app that's run in a docker container, using docker-compose. The line that should launch puppeteer...
Read more >
How to use Puppeteer inside a Docker container
FROM node:slim AS app # We don't need the standalone Chromium ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true # Install Google Chrome Stable and fonts ...
Read more >
A critical error: Chromium revision is not downloaded.
A critical error: Chromium revision is not downloaded. ... So, I opened Docker on my Mac and click through the dialog boxes and...
Read more >
Puppeteer on Render - Render community
im trying to run Puppeteer and im getting this error ... Run npm install to download the correct Chromium revision (1045629).” –pa…
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