
We didn’t specify the Node.js runtime version, so node is an alias to node:latest, which right now points to Node.js version 18.2.0 What happens when you build your Node.js Docker image based on this default node image, with just the fastify npm dependency?īuild the image with docker build -no-cache -f Dockerfile1 -t dockerfile1, and you get the following: The most common node image tags for the Debian distribution, such as bullseye or buster, are themselves based off of buildpack-deps, which are maintained by another team. There are also specific version tags to target CPU architectures such as amd64 or arm64x8 (the new Apple M1). It is officially maintained by the Node.js Docker team and contains several Docker base image tags, which map to different underlying distributions (Debian, Ubuntu, or Alpine) as well as to different versions of the Node.js runtime itself. Let's start off with the maintained node image. Let’s take a look at them one by one to learn more about the benefits and potential risks.Īuthor’s note: Throughout this article, I’ll compare a point-in-time Node.js version, which was last released around June 2022 and refers to Node.js 18.2.0. Out of all of these options, which Node.js Docker image is ideal for you? They range from the official Node.js Docker image that is maintained by the core Node.js team, to the specific Node.js image tags that you could choose from within that particular Docker base image, and even other options such as building your Node.js application on top of Google’s distroless project, or a bare bones scratch image provided by the Docker team.

There are actually quite a few options you could go for when building your Node.js image.

I have previously outlined and provided a step-by-step guide on 10 best practices to containerize Node.js web applications with Docker, which builds on and improves the example to achieve a production-ready Node.js Docker image.įor this post, we’ll use the contrived example above as the contents of a Dockerfile in order to find an ideal Node.js Docker image.
