Closed firstval closed 4 years ago
I've been running into this as well - I copy in the bundle, unzip all the files, and I can see that /aws/dist/aws
exists. I can ls
the directory and stat
the file and it's right there, but calling /aws/dist/aws --version
fails, saying the file cannot be found, both in the install script and as its own command.
In addition, this also seems to point to a bug where the installer can fail to actually install, but report success anyway, which is a problem.
EDIT: You can reproduce the issue using this Dockerfile:
FROM docker:stable
RUN apk add curl
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
RUN unzip awscliv2.zip
RUN ./aws/install -i /usr/local/aws -b /usr/local/bin/aws
RUN aws --version && docker -v
I'm seeing output like:
Step 5/6 : RUN ./aws/install -i /usr/local/aws -b /usr/local/bin/aws
---> Running in f60e4ff7f68e
./aws/install: line 78: /aws/dist/aws: not found
You can now run: /usr/local/bin/aws/aws --version
Removing intermediate container f60e4ff7f68e
---> 3a711e9989ae
Step 6/6 : RUN aws --version && docker -v
---> Running in 5015c32e62fe
/bin/sh: aws: Permission denied
The command '/bin/sh -c aws --version && docker -v' returned a non-zero code: 127
Which exhibits the strange behavior where the installation seems to fail on line 78 of the installer, but the install script still seems to succeed, only then to have it fail when we try to actually run the installed bin.
FYI Found same issues here: https://github.com/aws/aws-cli/issues/4685#issuecomment-556436861
Hi @firstval, it looks like you found a response on this behavior in #4685. We're currently tracking Docker support in #3553 which would be a prerequisite for this to work.
That said, we can definitely do better with the exceptions being returned. We're working on getting a warning in our install script to will alert you when the platform isn't supported.
We'll track the remaining piece for alpine support in #3553. Thanks!
stat
Just to add my feddback, I have the exact same error about the aws file not existing, but it actually does, as ls
confirmed.
I've got the same error:
/bin/sh: aws: not found
A comment that may not be relevant, but as Alpine uses a different runtime, musl, rather than glibc, could this be the issue? Essentially the binary file presented in the awscli v2 zip file is simply not compatible with Alpine?
@rquadling That is exactly correct. They're looking to see if they can adapt to that, or at least make the errors more helpful, but that's the issue.
I have the same issue. Would like to use the aws client to upload minified assets to S3 during build time. But using aws on Alpin is currently a pain in the ass. Version 1.X of aws doesn't support recursive uploads and version 2.0 of aws doesn't run correctly on Alpine. Would be nice if this would be fixed.
I don't have a solution for Alpine, but I have got AWSCLI v2, Terraform, and JQ all off of Amazon Linux.
# Based upon https://github.com/aws/aws-cli/blob/2.0.10/docker/Dockerfile
FROM amazonlinux:2 as installer
ARG TERRAFORM_VERSION
RUN yum update -y \
&& yum install -y unzip \
&& curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscli-exe-linux-x86_64.zip \
&& unzip awscli-exe-linux-x86_64.zip \
# The --bin-dir is specified so that we can copy the
# entire bin directory from the installer stage into
# into /usr/local/bin of the final stage without
# accidentally copying over any other executables that
# may be present in /usr/local/bin of the installer stage.
&& ./aws/install --bin-dir /aws-cli-bin/ \
&& curl "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -o terraform.zip \
&& unzip terraform.zip
FROM amazonlinux:2
COPY --from=installer /usr/local/aws-cli/ /usr/local/aws-cli/
COPY --from=installer /aws-cli-bin/ /usr/local/bin/
COPY --from=installer terraform /usr/bin/
RUN yum update -y \
&& yum install -y less groff jq \
&& yum clean all
ENTRYPOINT ["/bin/sh"]
Why was this closed? Installation of awscli-v2 on Alpine is still failing.
My understanding is that it was closed because Alpine isn't officially supported. There's some links to other issues further up in the thread about potentially adding it, or at least adding some sort of workaround.
Just come across this : https://hub.docker.com/r/atlassian/pipelines-awscli Does this work for v2?
Just come across this : https://hub.docker.com/r/atlassian/pipelines-awscli Does this work for v2?
Hello, I doubt it can work with CLI version 2. You have to use this kind of image, Alpine with glibc
.
Or use the custom Dockerfile described in this issue
I took a different route and installed the aws cli via pip
reference: https://stackoverflow.com/questions/61918972/how-to-install-aws-cli-on-alpine
Use https://git.adelielinux.org/adelie/gcompat
apk add gcompat
source: https://wiki.alpinelinux.org/wiki/Running_glibc_programs
@AnthonyWC It doesn't work. Error relocating /usr/local/bin/aws: strcat_chk: symbol not found Error relocating /usr/local/bin/aws: __snprintf_chk: symbol not found Error relocating /usr/local/bin/aws: vfprintf_chk: symbol not found Error relocating /usr/local/bin/aws: realpath_chk: symbol not found Error relocating /usr/local/bin/aws: __memcpy_chk: symbol not found Error relocating /usr/local/bin/aws: vsnprintf_chk: symbol not found Error relocating /usr/local/bin/aws: __strcpy_chk: symbol not found Error relocating /usr/local/bin/aws: __fprintf_chk: symbol not found
(Care to elaborate as to why installing via pip
is considered so bad?)
@marcelloromani - the lone, working pip
solution in that StackOverflow thread you linked produces aws-cli@1.x
People in this thread are interested in 2.x
. I'm not sure they have a problem with pip
itself.
Hi all,
Please review the recently proposed source distribution for the AWS CLI v2 that has shown success (via third party) for building on Alpine Linux:
https://github.com/aws/aws-cli/pull/6352#issuecomment-909083091
There is also an example in the proposal for building on an Alpine Linux container image:
https://github.com/kyleknap/aws-cli/blob/source-proposal/proposals/source-install.md#alpine-linux
Damn, thanks @drewlustro I must have looked at this in haste.
This worked for me :
apk update
apk add --update py-pip
python -m pip install awscli
This worked for me :
apk update apk add --update py-pip python -m pip install awscli
this install aws cli v1 for me.
Still up to date, the issue is from 2 years ago. Any intention to fix this?
This container works for me (using alpine:3.16
)
For other container I just add:
# =================== #
# Install AWSCli v2 #
# =================== #
COPY --from=devopscorner/aws-cli:latest /usr/local/aws-cli/ /usr/local/aws-cli/
COPY --from=devopscorner/aws-cli:latest /usr/local/bin/ /usr/local/bin/
I also had similar issue, when I gone through the AWS documentation, found I have to install following packages as a prerequisite:
glibc, groff, and less
groff and less both are available in Alpine Linux repo, but couldn't find glibc package. However I used musl and gcompat as an alternative (suggested here) which has fixed the issue. Now I can't see any errors during installation.
RUN ./aws/install -i /usr/local/aws-cli -b /usr/bin You can now run: /usr/bin/aws --version RUN aws --version aws-cli/2.1.18 Python/3.7.3 Linux/4.14.299-223.520.amzn2.x86_64 exe/x86_64.alpine.3 prompt/off
Hope this might help others with awscliv2 installation in Alpine Linux.
FROM alpine:edge
RUN echo -e -n "\n@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories RUN apk add aws-cli-v2@testing --no-cache
This container works for me (using
alpine:3.16
)
@zeroc0d3 have you ran into this issue with alpine3.13+ ? have you fixed it somehow ?
https://github.com/aws/aws-cli/issues/4685#issuecomment-1441909537
Feb 27, I realized that there is aws documentation for the cli v2 in alpine linux as mentioned in this issue 4685.
COPY --from=devopscorner/aws-cli:latest /usr/local/aws-cli/ /usr/local/aws-cli/ COPY --from=devopscorner/aws-cli:latest /usr/local/bin/ /usr/local/bin/
Not working for me on alpine:3.17
, getting the error:
qemu-x86_64: Could not open '/lib/ld-musl-x86_64.so.1': No such file or directory
I'm on arm64
though so may need to explicitly state which architecture?
For Alpine linux this worked for me
apk add --no-cache aws-cli
@jarbot
For Alpine linux this worked for me
apk add --no-cache aws-cli
It will install verion 1.X
/usr/src/app # aws --version
aws-cli/1.22.81 Python/3.10.12 Linux/5.4.242-156.349.amzn2.x86_64 botocore/1.21.49
@HamidullahMuslih
@jarbot
For Alpine linux this worked for me
apk add --no-cache aws-cli
It will install verion 1.X
/usr/src/app # aws --version aws-cli/1.22.81 Python/3.10.12 Linux/5.4.242-156.349.amzn2.x86_64 botocore/1.21.49
Worked for me.
I'm using php:8.26-fpm-alpine image.
It is already possible to install aws-cli v2.13.0
natively on Alpine v3.18.
I will put my comment that I made in another issue explaining: https://github.com/aws/aws-cli/issues/4685#issuecomment-1631152031
It is already possible to install
aws-cli v2.13.0
natively on Alpine v3.18.I will put my comment that I made in another issue explaining: #4685 (comment)
@thanks @wsalles . I just used apk :package: btw it looks like kubectl is already in alpine edge . I can't wait to add it as a binary :package: just like aws-cli
we need improve this Dockerfile but works for me
FROM alpine:3.17
ARG AWSCLI_VERSION=2.11.20
# set timezone America/Lima
ENV TZ=America/Lima
ENV TF_CLI_CONFIG_FILE=/home/terraformrc
ARG TERRAGRUNT_VERSION=latest
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
RUN apk update && apk add --no-cache \
wget=1.21.4-r0 \
curl=8.1.2-r0 \
unzip=6.0-r13 \
bash=5.2.15-r0 \
jq=1.6-r2 \
gettext=0.21.1-r1 \
python3=3.10.12-r0 \
py3-pip=22.3.1-r1 \
#install jq
jo=1.9-r0 \
nodejs=18.16.1-r0 \
# nodejs \
npm=9.1.2-r0 \
#install yq
yq=4.30.4-r4 \
&& rm -rf /var/cache/apk/*
# Install Docker dependencies
RUN apk add --no-cache \
docker=20.10.24-r2 \
openrc=0.45.2-r7 \
&& rc-update add docker boot
#upgrade pip and set timezone
RUN pip install --no-cache-dir \
boto3==1.26.46 \
pyYAML==5.4.1 \
htmlmin==0.1.12 \
Jinja2==3.1.2 \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& curl -s https://releases.hashicorp.com/terraform/1.4.6/terraform_1.4.6_linux_amd64.zip -o /tmp/terraform_1.4.6_linux_amd64.zip && \
unzip /tmp/terraform_1.4.6_linux_amd64.zip -d /tmp/ && \
chmod +x /tmp/terraform && mv /tmp/terraform /usr/bin/ && \
rm -rf /tmp/terraform_1.4.6_linux_amd64.zip && \
TERRAGRUNT_VERSION_INSTALL=$(curl -s https://api.github.com/repos/gruntwork-io/terragrunt/releases/latest | grep tag_name | cut -d '"' -f 4) && \
curl -LO https://github.com/gruntwork-io/terragrunt/releases/download/"${TERRAGRUNT_VERSION_INSTALL}"/terragrunt_linux_amd64 && \
chmod +x terragrunt_linux_amd64 && \
mv terragrunt_linux_amd64 /usr/bin/terragrunt
#install awscli
#depencies for awscli v2
RUN apk add --no-cache \
git=2.38.5-r0 \
groff=1.22.4-r2 \
less=608-r1 \
mailcap=2.1.54-r0 \
build-base=0.5-r3 \
libffi-dev=3.4.4-r0 \
cmake=3.24.4-r0 \
openssl-dev=3.0.9-r1 \
python3-dev=3.10.12-r0
WORKDIR /tmp
RUN git clone --single-branch --depth 1 -b "${AWSCLI_VERSION}" https://github.com/aws/aws-cli.git && \
./aws-cli/configure --with-install-type=portable-exe --with-download-deps && \
make && \
make install && \
rm -rf /tmp/aws-cli \
&& rm -rf \
/usr/local/lib/aws-cli/aws_completer \
/usr/local/lib/aws-cli/awscli/data/ac.index \
/usr/local/lib/aws-cli/awscli/examples \
&& find /usr/local/lib/aws-cli/awscli/data -name "completions-1*.json" -delete && \
find /usr/local/lib/aws-cli/awscli/botocore/data -name examples-1.json -delete
WORKDIR /usr/local/lib/aws-cli
RUN for a in *.so*; do test -f "/lib/$a" && rm "$a"; done
ENTRYPOINT ["/usr/bin/terraform"]
Highly annoying that installing aws cli has become so complicated in v2. Not only this issue with Alpine but also the need to choose between right CPU architecture when you download the zip.
I made this Gist incase it helps someone else https://gist.github.com/TeemuKoivisto/a99d51a2e4d86ebefad353ab2d4273ae
@nielsbaltodanomatrix with a Dockerfile like that I cant help but wonder what the benefit is of using Alpine. I just did a test build and it seems like that container comes in around 1.4GB in size. At that point I would just use Ubuntu as the base image instead, and you would avoid the issue of compatibility with aws
as well
Hopefully it's old news by now but it's finally dead easy to install aws cli v2 on alpine.
FROM alpine:3.18.4
RUN apk add --no-cache aws-cli
$ docker build -t aws-cli-v2-alpine .
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
aws-cli-v2-alpine latest d575d170a8f1 12 seconds ago 170MB
$ docker run --rm -it aws-cli-v2-alpine aws --version
aws-cli/2.13.5 Python/3.11.6 Linux/5.10.124-linuxkit source/aarch64.alpine.3 prompt/off
Tested on Mac OS 14.0 Docker Desktop 4.12.0
Hopefully it's old news by now but it's finally dead easy to install aws cli v2 on alpine.
FROM alpine:3.18.4 RUN apk add --no-cache aws-cli
$ docker build -t aws-cli-v2-alpine .
$ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE aws-cli-v2-alpine latest d575d170a8f1 12 seconds ago 170MB
$ docker run --rm -it aws-cli-v2-alpine aws --version aws-cli/2.13.5 Python/3.11.6 Linux/5.10.124-linuxkit source/aarch64.alpine.3 prompt/off
Tested on Mac OS 14.0 Docker Desktop 4.12.0
@marcelloromani this is really great. awscli is in 3.18 branch . I can't wait for kubectl to move to the next stable branch. the image is really tiny and it works in arm64
For Anyone still facing this issue, use
apk add --no-cache aws-cli
to install aws-cli
The error is still present for the image alpine:edge on architecture x86_64:
Command runned : apk add --no-cache aws-cli
Docker Image : alpine:edge
-> Package is not present for the architecture x86_64 : https://pkgs.alpinelinux.org/packages?name=aws-cli&branch=edge&repo=&arch=x86_64&maintainer=None (only for Arch)
At this moment of writing, aws-cli
is only available natively in Alpine 3.19, not 3.20 and edge
https://pkgs.alpinelinux.org/packages?name=aws-cli&branch=v3.19&repo=&arch=&maintainer=
Thanks @gnought 🙏
currently build our Dockerfile
is failure, so i arrived this issue.
our workaround is below, based on this comment https://github.com/aws/aws-cli/issues/4971#issuecomment-2126734523
- FROM alpine:latest
+ FROM alpine:3.19
RUN apk add --no-cache aws-cli
CMD ["/bin/sh"]
※ but we don't understand why now it's impossible to add use alpine:latest
I guess the page is a bit outdated. Today I found that aws-cli v2 is now available in alpine:3.20
gnought:~ √ % docker run --rm -it --pull always alpine:3.20 sh
3.20: Pulling from library/alpine
Digest: sha256:77726ef6b57ddf65bb551896826ec38bc3e53f75cdde31354fbffb4f25238ebd
Status: Image is up to date for alpine:3.20
/ # apk add aws-cli
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/aarch64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/aarch64/APKINDEX.tar.gz
(1/62) Installing libbz2 (1.0.8-r6)
(2/62) Installing libexpat (2.6.2-r0)
(3/62) Installing libffi (3.4.6-r0)
(4/62) Installing gdbm (1.23-r1)
(5/62) Installing xz-libs (5.6.1-r3)
(6/62) Installing libgcc (13.2.1_git20240309-r0)
(7/62) Installing libstdc++ (13.2.1_git20240309-r0)
(8/62) Installing mpdecimal (4.0.0-r0)
(9/62) Installing ncurses-terminfo-base (6.4_p20240420-r0)
(10/62) Installing libncursesw (6.4_p20240420-r0)
(11/62) Installing libpanelw (6.4_p20240420-r0)
(12/62) Installing readline (8.2.10-r0)
(13/62) Installing sqlite-libs (3.45.3-r1)
(14/62) Installing python3 (3.12.3-r1)
(15/62) Installing python3-pycache-pyc0 (3.12.3-r1)
(16/62) Installing pyc (3.12.3-r1)
(17/62) Installing py3-certifi (2024.2.2-r1)
(18/62) Installing py3-certifi-pyc (2024.2.2-r1)
(19/62) Installing py3-cparser (2.22-r1)
(20/62) Installing py3-cparser-pyc (2.22-r1)
(21/62) Installing py3-cffi (1.16.0-r1)
(22/62) Installing py3-cffi-pyc (1.16.0-r1)
(23/62) Installing py3-cryptography (42.0.7-r0)
(24/62) Installing py3-cryptography-pyc (42.0.7-r0)
(25/62) Installing py3-six (1.16.0-r9)
(26/62) Installing py3-six-pyc (1.16.0-r9)
(27/62) Installing py3-dateutil (2.9.0-r1)
(28/62) Installing py3-dateutil-pyc (2.9.0-r1)
(29/62) Installing py3-distro (1.9.0-r2)
(30/62) Installing py3-distro-pyc (1.9.0-r2)
(31/62) Installing py3-colorama (0.4.6-r5)
(32/62) Installing py3-colorama-pyc (0.4.6-r5)
(33/62) Installing py3-docutils (0.20.1-r2)
(34/62) Installing py3-docutils-pyc (0.20.1-r2)
(35/62) Installing py3-jmespath (1.0.1-r3)
(36/62) Installing py3-jmespath-pyc (1.0.1-r3)
(37/62) Installing py3-urllib3 (1.26.18-r1)
(38/62) Installing py3-urllib3-pyc (1.26.18-r1)
(39/62) Installing py3-wcwidth (0.2.13-r1)
(40/62) Installing py3-wcwidth-pyc (0.2.13-r1)
(41/62) Installing py3-prompt_toolkit (3.0.43-r1)
(42/62) Installing py3-prompt_toolkit-pyc (3.0.43-r1)
(43/62) Installing py3-ruamel.yaml.clib (0.2.8-r1)
(44/62) Installing py3-ruamel.yaml (0.17.28-r1)
(45/62) Installing py3-ruamel.yaml-pyc (0.17.28-r1)
(46/62) Installing aws-cli-pyc (2.15.57-r0)
(47/62) Installing py3-awscrt-pyc (0.20.3-r1)
(48/62) Installing python3-pyc (3.12.3-r1)
(49/62) Installing aws-c-common (0.9.19-r0)
(50/62) Installing aws-c-cal (0.6.14-r0)
(51/62) Installing aws-c-compression (0.2.18-r0)
(52/62) Installing s2n-tls (1.4.14-r0)
(53/62) Installing aws-c-io (0.14.8-r0)
(54/62) Installing aws-c-http (0.8.1-r0)
(55/62) Installing aws-c-sdkutils (0.1.16-r0)
(56/62) Installing aws-c-auth (0.7.22-r0)
(57/62) Installing aws-checksums (0.1.17-r1)
(58/62) Installing aws-c-event-stream (0.4.2-r0)
(59/62) Installing aws-c-mqtt (0.10.4-r0)
(60/62) Installing aws-c-s3 (0.5.9-r0)
(61/62) Installing py3-awscrt (0.20.3-r1)
(62/62) Installing aws-cli (2.15.57-r0)
Executing busybox-1.36.1-r28.trigger
OK: 189 MiB in 76 packages
/ # aws --version
aws-cli/2.15.57 Python/3.12.3 Linux/6.9.3-orbstack-00146-g1a8d02c90788 source/aarch64.alpine.3
I tried to install aws cli v2 with alpine using docker but after installation it doesn't find the aws command even the directories existing. I tried using the following commands