I was trying to put awscli_v2 into an alpine-based docker container and see that it fails with the following error message:
/aws/install: line 78: /aws/dist/aws: not found
Considering that the file itself is there and can be listed with ls, I would guess that some libraries that the executable ./aws/dist/aws relies upon are not present on alpine. Does someone know which libraries that might be?
AWS CLI version 2 is compiled against glibc, the GNU Project's implementation of the C standard library. Most common Linux distributions use glibc, but Alpine Linux is instead based on musl libc.
Because binaries compiled against glibc aren't compatible with musl, AWS CLI version 2 doesn't run on Alpine Linux.
The best way to run AWS CLI version 2 on Alpine Linux would be for Amazon to provide one of the following:
Actually with a bit a effort it is possible to run AWS CLI v2 on Alpine:
FROM alpine:3.11
ENV GLIBC_VER=2.31-r0
# 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_VER}/glibc-${GLIBC_VER}.apk \
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk \
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-i18n-${GLIBC_VER}.apk \
&& apk add --no-cache \
glibc-${GLIBC_VER}.apk \
glibc-bin-${GLIBC_VER}.apk \
glibc-i18n-${GLIBC_VER}.apk \
&& /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8 \
&& curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64.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/*
The above Dockerfile will install the 'glibc' package for Alpine, so that the AWS CLI will be able to find the required shared libraries. The Dockerfile also removes some stuff we probably don't need, such as auto-complete and examples. If you need some other specific packages you can of course add them to the Dockerfile.
Can also use https://git.adelielinux.org/adelie/gcompat
apk add gcompat
source: https://wiki.alpinelinux.org/wiki/Running_glibc_programs
Edit sample:
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
Modifying a bit AnthonyC's answer does the trick:
FROM frolvlad/alpine-glibc:alpine-3.14
ENV AWS_CLI_VER=2.2.43
RUN apk update && apk add --no-cache curl zip && \
curl -s https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VER}.zip -o awscliv2.zip && \
unzip awscliv2.zip && ./aws/install