aws-cli-v2 issue with alpine using Docker

Created on 18 Feb 2020  路  13Comments  路  Source: aws/aws-cli

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

/ # apk add --no-cache curl
/ # curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
/ # unzip awscliv2.zip
/ # ./aws/install
./aws/install: line 78: /aws/dist/aws: not found
You can now run: /usr/local/bin/aws --version

/ # /usr/local/bin/aws --version
sh: /usr/local/bin/aws: not found

/ # aws --version
sh: aws: not found

/ # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

/ # ls /usr/local/bin
aws            aws_completer

Most helpful comment

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

All 13 comments

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

Was this page helpful?
0 / 5 - 0 ratings