1 Answer
- Newest
- Most votes
- Most comments
4
Hlo,
t seems like you're facing compatibility issues with the GLIBC version when trying to install Node.js 20 on Amazon Linux 2, which comes with GLIBC version 2.26. Node.js 20 requires a higher version of GLIBC (specifically GLIBC 2.28).
# Use an image with the necessary GLIBC version
FROM public.ecr.aws/amazonlinux/amazonlinux:2 as builder
# Install Node.js 20
RUN curl --silent --location https://rpm.nodesource.com/setup_20.x | bash -
RUN yum install -y nodejs
# Final image
FROM amazon/aws-cli:2.8.3
# Copy Node.js from the builder image
COPY --from=builder /usr/bin/node /usr/bin/node
COPY --from=builder /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6
COPY --from=builder /usr/lib64/libgcc_s.so.1 /usr/lib64/libgcc_s.so.1
# Other dependencies and cleanup
RUN yum install -y which zip \
&& yum clean all \
&& rm -rf /var/cache/yum
# Confirm Node.js and npm versions
RUN node -v && npm -v
This Docker file starts by using the Amazon Linux 2 base image. Then it installs Node.js 20 from the Node Source repository. The crucial part is copying necessary Node.js files and dependencies from the builder image to the final image. This ensures that the GLIBC version compatibility issue is resolved.
Please note that this Docker file assumes you have access to the AWS CLI image and necessary permissions to pull it.
Relevant content
- asked 2 months ago
- asked 2 years ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 10 months ago
Hi Thanniru,
I tried the approach you mentioned but with the dockerfile you shared the issue is you are still using amazonlinux:2 as builder hence when in the next step it tries to install node 20 it gets the same error of glibc version incompatibility
now in place of amazonlinux:2 if i use amazonlinux:2023 as builder than my build pipeline is failing again with the error: Errors during downloading metadata for repository 'amazonlinux': Curl error (6): Couldn't resolve host name for https://cdn.amazonlinux.com/al2023/core/mirrors/2023.4.20240429/x86_64/mirror.list [getaddrinfo() thread failed to start]
so this is kind of going in loop. i tried using the image provided by amazon which is FROM public.ecr.aws/lambda/nodejs:20
but in this case my when my pipeline try to push my image it seems to be giving 503 service unavailable error
any further leads would help