我对 docker 和 aws 的了解有限 我正在尝试将nodejs从16更新到20,但我收到此错误“错误包:2:nodejs-20.12.2-1nodesource.x86_64(nodesource-nodejs)需要:libc.so.6(GLIBC_2.28)( 64位)”
我的
Dockerfile
:
FROM amazon/aws-cli:2.8.3
RUN yum update -y \
&& curl --silent --location https://rpm.nodesource.com/setup_20.x | bash - \
&& yum install -y nodejs which zip \
&& yum clean all \
&& rm -rf /var/cache/yum
此错误的原因是 aws-cli 使用的是 amazonlinux:2,它只有 glibs 版本 2.26
同样的
Dockerfile
适用于nodejs 16版本。
我尝试了各种方法,例如使用 amzonlinus:2023 作为安装程序
Dockerfile
:
FROM amazon/aws-cli:2.15.42
FROM public.ecr.aws/amazonlinux/amazonlinux:2023 as installer
RUN yum update -y \
&& curl --silent --location https://rpm.nodesource.com/setup_20.x | bash - \
&& yum install -y nodejs which zip \
&& yum clean all \
&& rm -rf /var/cache/yum
但这也未能说明
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]
我也尝试使用亚马逊码头图像,但这也不起作用
FROM public.ecr.aws/lambda/nodejs:20.2024.05.01.10
有人可以帮助我并分享一个可以安装nodejs 20的
Dockerfile
吗?
你提到
public.ecr.aws/lambda/nodejs:20.2024.05.01.10
不起作用。那里出了什么问题?
这肯定会给你 Node 20。
FROM public.ecr.aws/lambda/nodejs:20
ENTRYPOINT [ "/bin/bash" ]
为了便于说明,我将 BASH 设置为入口点,在下面的屏幕截图中,您可以看到 Node 20 确实在那里!
如果您特别希望在映像上使用 AWS CLI,那么您可以考虑替代选项。
FROM node:20-slim
RUN apt-get update -q && \
apt-get install -q -y awscli
现在您已经拥有 Node 20 和 AWS CLI。