nodejs / docker-node

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

Error: Unable to load metadata on arm64v8 #2110

Closed amoya-revo closed 3 months ago

amoya-revo commented 3 months ago

Environment

Expected Behavior

It should be able to get the image and metadata from repositosy

Current Behavior

Docker is not being able to locate the metadata. This behavior started on 24/Jun/2024 on tag latest and today is affecting other images (alpine3.19, alpine-lts)

#5 [internal] load metadata for docker.io/arm64v8/node:lts-alpine
#5 ERROR: no match for platform in manifest: not found

#4 [internal] load metadata for docker.io/library/node:latest
#4 CANCELED
------
 > [internal] load metadata for docker.io/arm64v8/node:lts-alpine:
------
dockerfile:21
--------------------
  19 |     
  20 |     # Stage 2: Setup the production environment
  21 | >>> FROM arm64v8/node:lts-alpine
  22 |     
  23 |     WORKDIR /usr/src/app
--------------------
ERROR: failed to solve: arm64v8/node:lts-alpine: failed to resolve source metadata for docker.io/arm64v8/node:lts-alpine: no match for platform in manifest: not found
Error: Process completed with exit code 1.

Possible Solution

Steps to Reproduce

build an image using arm64v8 alpine images

Additional Information

yosifkit commented 3 months ago

The arm64v8/node images are now an image index (with a provenance and SBOM doc), so if they are pulled from a non-arm64v8 host then a platform specification (like --platform=linux/arm64) is required for docker to pull it correctly.

amoya-revo commented 3 months ago

Thanks a lot! It worked as a charm

amoya-revo commented 3 months ago

Thanks again

natcl commented 3 months ago

Out of curiosity is there a workaround for this ? When using gitlab ci there is sadly no current way to specify --platform when they pull the image so the newer images break...

Related to this issue: https://gitlab.com/gitlab-org/gitlab/-/issues/392011

LaurentGoderre commented 3 months ago

@natcl are you trying to build cross-platform? If not dropping the architecture namespace should do the trick

natcl commented 3 months ago

Yes in my case I'm trying to build arm64 on AMD64... I was able to get around by fetching a generic arm64v8/alpine image and installing node manually in it, that specific image doesn't trigger the same error. Wish gitlab would fix the issue however...

natcl commented 2 months ago

For anyone having the same issue with gitlab, the support for platform is actually in the latest runners: https://docs.gitlab.com/17.1/ee/ci/yaml/#imagedocker

amoya-revo commented 2 months ago

if it helps in any form, this is my dockerfile including the platform specification - in stage 2

# Use a multi-stage build to reduce the image size # Stage 1: Build the application FROM node:latest as builder WORKDIR /usr/src/app COPY ./package*.json ./ RUN npm install COPY . . RUN npm run build

# Stage 2: Setup the production environment FROM --platform=linux/arm64 arm64v8/node:lts-alpine WORKDIR /usr/src/app COPY --from=builder /usr/src/app/dist ./dist COPY --from=builder /usr/src/app/node_modules ./node_modules EXPOSE 3000 CMD [ "node", "dist/main"]

natcl commented 2 months ago

Interesting, can be a nice workaround !