Video Thumbnail for Lesson
6.6: Choosing a Base Image

Choosing a Base Image

When choosing a base image for your container, it's important to consider factors such as size, language support, ergonomics, and security. In this guide, we'll discuss these considerations and present some sample images for a Node.js application.

Factors to Consider

  1. Size: The base image size is the lower bound of the final built image size.
  2. Language Support: Ensure that the base image supports the language you're running.
  3. Ergonomics: How easy is it to work with the image? Does it have utilities built in for debugging or package installation?
  4. Security: Consider the number of CVEs (Common Vulnerabilities and Exposures) and the attack surface area of the image.

Sample Images for Node.js Applications

Table summarizing base image choices

Here are some sample images for a Node.js application, with their respective sizes and vulnerabilities:

  1. node:latest (Bullseye) - Almost 1 GB in size, with 5 critical vulnerabilities, but easy to work with.
  2. node:slim (Bullseye) - 4 times smaller than the full size image and eliminates critical vulnerabilities, but with fewer built-in utilities.
  3. node:alpine - Small and free of CVEs, but considered experimental by Node.js due to its different C library variant.
  4. - Security-focused image created by Google, with LTS Node.js support only and limited utilities.
  5. - Smallest and most secure image, but may be more difficult to work with due to its software provenance and limited package support.


For general-purpose use, the node:slim (Bullseye) image is a good choice due to its balance between size, security, and ease of use.

If you're focused on security, consider using the chainguard/nodejs image, but be prepared for potential difficulties in working with certain packages or custom application needs.