Reputation: 319
Hi I am new to the Docker and node. I want to know what does this line means?
FROM node:12.2.0-alpine
What the relationship between node and alpine?
And what if I want to use the newest version of node, what should I change?
Thank you so much!
Upvotes: 21
Views: 26742
Reputation: 12863
I know that alpine
means a smaller container size, but I'm mainly concerned about what you're missing out on if you switch to alpine
.
From this 2022 blog post 'Choosing the best Node.js Docker image'...
Good:
This will yield a Docker image size of 196MB, which shaves off 64MB from the slim Node.js images, and in the Alpine image tag — as of the day I’m writing this — there are only 17 operating system dependencies and zero security vulnerabilities were detected.
Bad:
- However, it’s important to recognize that the Alpine project uses musl as the implementation for the C standard library, whereas Debian’s Node.js image tags such as
bullseye
orslim
rely on theglibc
implementation.- Choosing a Node.js alpine image tag means you are effectively choosing an unofficial Node.js runtime.
- Unofficial-builds attempts to provide basic Node.js binaries for some platforms that are either not supported or only partially supported by Node.js. This project does not provide any guarantees and its results are not rigorously tested.
Some notable observations with Node.js
alpine
image tag compatibility are:
- Yarn being incompatible (issue #1716).
- If you require
node-gyp
for cross-compilation of native C bindings, then Python, which is a dependency of that process, isn’t available in the Alpine image and you will have to sort it out yourself (issue #1706).
Upvotes: 2
Reputation: 749
From node:alpine:
This image is based on the popular Alpine Linux project, available in the alpine official image. Alpine Linux is much smaller than most distribution base images, and thus leads to much slimmer images in general. This variant is highly recommended when final image size being as small as possible is desired.
Upvotes: 0
Reputation: 1951
Alpine is the base image which is based on Alpine Linux, a very compact Linux distribution. So, node:12.2.0-alpine is a Alpine Linux image with node 12.2.0 installed.
For the latest Alpine based image you can simply do node:alpine
. If you want latest but not specifically Alpine you can do node:latest
, that image will be based on stretch which is a Debian distribution.
You can find a full list of all supported tags here: https://hub.docker.com/_/node/
Upvotes: 25