我试图将awscli_v2放入一个基于阿尔卑斯山的码头容器中,并确保它在出现以下错误消息时失败:
/aws/install:第78行: /aws/dist/aws: not
考虑到文件本身就在那里,并且可以用ls列出,我猜想可执行./aws/dist/aws
所依赖的一些库并不存在于高山上。有人知道哪些图书馆可能是吗?
发布于 2020-04-17 09:45:34
实际上,只要稍加努力,就可以在高山上运行AWS v2:
ARG ALPINE_VERSION=3.15.4
FROM alpine:${ALPINE_VERSION}
ARG GLIBC_VERSION=2.35-r0
ARG AWSCLI_VERSION=2.6.1
# install glibc compatibility for alpine
RUN apk --no-cache add \
binutils \
curl \
&& curl -sL https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub \
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk \
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk \
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-i18n-${GLIBC_VERSION}.apk \
&& apk add --no-cache \
glibc-${GLIBC_VERSION}.apk \
glibc-bin-${GLIBC_VERSION}.apk \
glibc-i18n-${GLIBC_VERSION}.apk \
&& /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8 \
&& ln -sf /usr/glibc-compat/lib/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2 \
&& curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWSCLI_VERSION}.zip -o awscliv2.zip \
&& unzip awscliv2.zip \
&& aws/install \
&& rm -rf \
awscliv2.zip \
aws \
/usr/local/aws-cli/v2/current/dist/aws_completer \
/usr/local/aws-cli/v2/current/dist/awscli/data/ac.index \
/usr/local/aws-cli/v2/current/dist/awscli/examples \
glibc-*.apk \
&& find /usr/local/aws-cli/v2/current/dist/awscli/botocore/data -name examples-1.json -delete \
&& apk --no-cache del \
binutils \
curl \
&& rm -rf /var/cache/apk/*
上面的Dockerfile将为Alpine安装'glibc‘包,以便AWS能够找到所需的共享库。Dockerfile还删除了一些我们可能不需要的东西,比如自动完成和示例。如果您需要其他一些特定的包,当然可以将它们添加到Dockerfile中。
更新2022-08-01
AWS已经改进了构建过程,所以现在也可以使用MUSL glibc (kudos到@Julian )从git构建:
ARG ALPINE_VERSION=3.16
FROM python:3.10.5-alpine${ALPINE_VERSION} as builder
ARG AWS_CLI_VERSION=2.9.0
RUN apk add --no-cache git unzip groff build-base libffi-dev cmake
RUN git clone --single-branch --depth 1 -b ${AWS_CLI_VERSION} https://github.com/aws/aws-cli.git
WORKDIR aws-cli
RUN python -m venv venv
RUN . venv/bin/activate
RUN scripts/installers/make-exe
RUN unzip -q dist/awscli-exe.zip
RUN aws/install --bin-dir /aws-cli-bin
RUN /aws-cli-bin/aws --version
# reduce image size: remove autocomplete and examples
RUN rm -rf \
/usr/local/aws-cli/v2/current/dist/aws_completer \
/usr/local/aws-cli/v2/current/dist/awscli/data/ac.index \
/usr/local/aws-cli/v2/current/dist/awscli/examples
RUN find /usr/local/aws-cli/v2/current/dist/awscli/data -name completions-1*.json -delete
RUN find /usr/local/aws-cli/v2/current/dist/awscli/botocore/data -name examples-1.json -delete
# build the final image
FROM alpine:${ALPINE_VERSION}
COPY --from=builder /usr/local/aws-cli/ /usr/local/aws-cli/
COPY --from=builder /aws-cli-bin/ /usr/local/bin/
上面的图片大小更小(从175 of减少到95 of),因为我们不再需要glibc攻击(但是我们必须使用特定版本的PyInstaller)。希望AWS也能分发阿尔卑斯双星,所以我们不必自己构建它。
发布于 2020-03-19 18:22:33
implementation 2是针对GNU实现C标准库的glibc编译的。大多数常见的Linux发行版都使用glibc,但是Alpine是基于musl libc的。
因为针对glibc编译的二进制文件与musl不兼容,所以2不能在阿尔卑斯Linux上运行。
在阿尔卑斯Linux上运行2的最佳方法是由Amazon提供以下内容之一:
发布于 2021-08-24 21:43:18
也可以使用https://git.adelielinux.org/adelie/gcompat
apk add gcompat
来源:节目
编辑样本:
ENV AWS_CLI_VER=2.0.30
RUN apk update && apk add --no-cache curl gcompat zip && \
curl -s https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VER}.zip -o awscliv2.zip && \
unzip awscliv2.zip && ./aws/install
https://stackoverflow.com/questions/60298619
复制相似问题