Selecting A Node.js Image for Docker

FROM node:x.x.x-(alpine|stretch|buster|bullseye)-slim WHAT???
FROM node:16

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
COPY . .

CMD [ "node", "server.js" ]
  • FROM creates a layer from the node:16 Docker image.
  • COPY adds files from your Docker client’s current directory.
  • RUN builds your application with make.
  • CMD specifies what command to run within the container.

FROM node:16-alpine:

FROM node:16-stretch:

FROM node:16-buster:

FROM node:16-bullseye:

FROM node:<version>:

FROM node:<version>-slim:

  • source controls software, such as git, subversion, bazaar, and mercurial
  • runtime libraries and build tools like make, gcc, g++, and others
  • libraries and API sets such as ImageMagick, a dozen another lib* libraries), and others

Our Recommendation: Alpine Linux:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store