#Puppeteer fails to launch chromium in docker container

4 messages · Page 1 of 1 (latest)

last marten
#

This is my dockerfile code:

FROM node:18-alpine As base

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true

RUN apk update && apk add curl gnupg \
    && curl --location --silent https://dl-ssl.google.com/linux/linux_signing_key.pub | apk add - \
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apk/sources.list.d/google.list' \
    && apk update \
    && apk add google-chrome-stable --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main \
    && rm -rf /var/cache/apk/*

USER node
WORKDIR /app

COPY --chown=node:node package*.json .

RUN npm ci

COPY --chown=node:node . .```

My backend is running inside a Docker container and is built with Nest Js. I want to save the PDF file after converting the HTML content. I'm using the Puppeteer library for that, and in order for my conversion to work, I need to run Chromium (whether it is headless or not).

When we run the command "npm i puppeteer," I assumed I didn't need to install Chrome. It worked during development, but for some reason it does not work in a Docker container.

I am not sure that the code in my Docker file will work to install Chrome. I got this code online and pasted it in my Docker file, but it shows the error

any solution to this?
icy spire
#

In my experience, chromium doesn't work in some of the linux distributions. I remember specially ubuntu.

#

I would try chrome or even firefox

#

There's no a simple solution though