Puppeteer Chrome browser not found error when running in Docker environment

I’m having trouble getting Puppeteer to function correctly within a Docker environment. Even after manually installing Chrome, I’m receiving an error that indicates it cannot find the browser.

The error message states:

Could not find Chrome (ver. 133.0.6943.98). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome`) or
 2. your cache path is incorrectly configured (which is: /root/.cache/puppeteer).

Here is how I’ve set up my Docker configuration:

# Environment setup
FROM node:18 AS base

ENV NODE_ENV=development
ENV NODE_OPTIONS="--max-old-space-size=2048"
ENV PUPPETEER_CACHE_DIR="/root/.cache/puppeteer"
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"

# Dependencies installation
FROM base AS dependencies

WORKDIR /application

RUN apt-get update && apt-get install -y wget gnupg curl \
    && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list' \
    && apt-get update && apt-get install -y google-chrome-stable \
    --no-install-recommends \
    && rm -rf /var/lib/apt/lists/*

COPY package.json yarn.lock* .yarnrc.yml ./
COPY .yarn/releases ./.yarn/releases

RUN yarn install
RUN npx puppeteer browsers install chrome

# Application build
FROM base AS build

WORKDIR /application

COPY --from=dependencies /application/node_modules ./node_modules
COPY . .

RUN yarn build

EXPOSE 3000
ENV PORT=3000

CMD ["yarn", "start"]

When I enter the container shell, I cannot locate where Chrome was installed. What could I be missing?

i had this problem too! u should try running the npx puppeteer browsers install chrome in your build stage after u copy node_modules. chrome might not be available when u copy it from dependency stage. also, consider removing the PUPPETEER_SKIP_CHROMIUM_DOWNLOAD env var!

Your problem is PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true - this stops Puppeteer from downloading its browser binaries. When you run npx puppeteer browsers install chrome after, it downloads Chrome to the cache directory, but your multi-stage build wipes this between stages. I’ve hit this same issue with production containers. You’re doing two conflicting things - installing Chrome via apt-get AND trying to use Puppeteer’s browser management. Pick one. Either drop the PUPPETEER_SKIP_CHROMIUM_DOWNLOAD variable and let Puppeteer handle everything, or keep the apt-get install but point Puppeteer to the system Chrome using executablePath: ‘/usr/bin/google-chrome-stable’. I’d go with the second option - it’s more reliable in Docker since you control the Chrome installation.

Your multi-stage Docker build is installing Chrome in the dependencies stage, but it’s not making it to the final build stage. You’re installing Chrome with apt-get, then again with npx puppeteer in dependencies, but only copying node_modules to the build stage. Had this exact problem last month. You need Chrome available in your final stage. Two ways to fix it: install Chrome directly in the build stage with apt-get, or copy the Puppeteer cache from dependencies using COPY --from=dependencies /root/.cache/puppeteer /root/.cache/puppeteer. I’d go with the second option - it’s more reliable and keeps the Chrome version synced with what Puppeteer wants.