Puppeteer in docker container: Chromium revision is not downloaded
See original GitHub issueI’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:
- Created 6 years ago
- Comments:14 (2 by maintainers)
Top GitHub Comments
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.Then when I use puppeteer in my JS code, I have to tell it what path to use (the ENV var I set above).
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)
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/
.