A Docker image with preinstalled Chromium and Node.JS on Alpine Linux or Debian. Good minimal base image for users of scraping libraries like Puppeteer.
https://github.com/shivjm/docker-node-chromium/
https://github.com/shivjm/docker-node-chromium/issues/
See all available tags at Docker Hub (shivjm/node-chromium). No latest
image is provided.
nodeN-chromiumC-alpine
, where N is the Node.js major version number (12, 14, 16, 17, 18, 19, 20, or 22) and C is the Chromium major version number. For example, to use Node.js 14 with Chromium 81, use the shivjm/node-chromium:node14-chromium81-alpine
image.
nodeN-chromiumC-debian
, where N is the Node.js major version number (12, 14, 16, 17, 18, 19, 20, or 22) and C is the Chromium major version number. For example, to use Node.js 14 with Chromium 81, use the shivjm/node-chromium:node14-chromium81-debian
image.
The newest version of Chromium provided by Alpine Linux or Debian is used.
The version of the base distribution depends on the upstream Node images.
Simple:
FROM shivjm/node-chromium:node14-chromium99-alpine
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci
COPY src .
ENTRYPOINT ["npm", "start"]
Multi-stage build to separate development dependencies from production:
FROM node:12-alpine AS build
WORKDIR /usr/src/app-deps
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run compile-my-code && \
npm prune --production
FROM shivjm/node-chromium:node18-chromium108-debian
USER node
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
COPY --from=build /usr/src/app-deps/node_modules ./node_modules
COPY --from=build /usr/src/app-deps/dist ./dist
ENV NODE_ENV=production
ENTRYPOINT ["npm", "start", "--quiet"]
When you install Puppeteer, it also downloads a known version of Chromium to store under node_modules, and defaults to using that binary. You can skip this download using the environment variable PUPPETEER_SKIP_CHROMIUM_DOWNLOAD
. You’ll also need to set PUPPETEER_EXECUTABLE_PATH
to the installed Chromium. A partial example:
# (setup elided)
# install dependencies but not Chromium:
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
RUN npm install
# make Puppeteer use correct binary:
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
# (other build details elided)