nodejs / docker-node

Official Docker Image for Node.js :whale: :turtle: :rocket:
https://hub.docker.com/_/node/
MIT License
8.13k stars 1.95k forks source link

Alpine images with the same tag have different versions on different platforms #2087

Closed godber closed 1 month ago

godber commented 1 month ago

Is it expected to have different alpine versions on different platforms for the same alpine tag?

For instance, pulling the node:22-alpine image on the amd64 and then the arm64 platforms show different versions of alpine being used. See steps to reproduce below.

Environment

Expected Behavior

I would expect the alpine versions to match.

Current Behavior

Currently they do not match

Possible Solution

Unsure yet.

Steps to Reproduce

docker run --rm --platform linux/amd64 -it node:22-alpine cat /etc/alpine-release
Unable to find image 'node:22-alpine' locally
22-alpine: Pulling from library/node
Digest: sha256:94567107148ac59f1eb2ad9b7c1db03f1a1a12d28717b29eda0535aa3bd2f71e
Status: Downloaded newer image for node:22-alpine
3.20.0

docker run --rm --platform linux/arm64 -it node:22-alpine cat /etc/alpine-release
Unable to find image 'node:22-alpine' locally
22-alpine: Pulling from library/node
Digest: sha256:94567107148ac59f1eb2ad9b7c1db03f1a1a12d28717b29eda0535aa3bd2f71e
Status: Downloaded newer image for node:22-alpine
3.19.1

Additional Information

If the alpine versions do not match, users who need node-gyp will encounter problems because the python version differs between alpine 3.19 and 3.20. Users will experience problems when doing import gyp ... they will see errors that contain:

#13 42.41 ModuleNotFoundError: No module named 'distutils'

It is possible to work around this problem by adding a line like this to their dockerfiles:

RUN python -c "import distutils" || apk update && apk add py3-setuptools
LaurentGoderre commented 1 month ago

This happens when there's a new version of the base image (alpine in this case). The amd64 alpine images uses pre-built binaries so they build very fast but the other arch build node from source which takes lot longer. In order not to break tags, they get update as they are ready

godber commented 1 month ago

Oh, that's interesting, thanks for the response. I guess that leaves me with the following questions:

Feel free to close this when you respond again or I'll just close if it stays open much longer. At least this gotcha is documented.

LaurentGoderre commented 1 month ago

Node from source takes a long time (over an hour) and our queue was quite busy with the release of alpine 3.20. With that being said, some arch are having a separate issue and the progress is being tracked at https://github.com/docker-library/official-images/issues/16830