Trying to upload a dockerfile to aws ecr - amazon-web-services

I'm trying to upload a dockerfile to AWS's ECR Service.
But when I issue the command
aws ecr get-login --no-include-email --region us-east-2
I get an error saying the host is down
'Connection aborted.', error(64, 'Host is down')
I'm using aws on a Mac
aws-cli/1.15.8 Python/2.7.10 Darwin/17.5.0 botocore/1.10.8
I tried to install python3 as indicated in the aws-docs, but it fails miserably with several errors. Python is always pointing to the Apple default install (in /usr/bin/python).
I tried about a dozen solutions from the web (including installing it via homebrew) - none of them helped.
I had to download the aws installer directly from amazon's servers, which worked:
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Any ideas?
[EDIT]
I'm actually still interested, why this all happens, but in the meantime, I abandoned AWS and switched to IBM-Bluemix. Deploying a Node-JS app was a breeze and took 5 minutes.

Related

yawsso can't find the right awscli

I am trying to use yawsso to login to aws. I have awscliv2 installed by following the instructions here.
Unfortunately I also seem to have aws version 1 on my computer as well.
So when I try
yawsso login --profile my-profile --this -e
I get the response:
Required AWS CLI v2. Found aws-cli/1.27.62 Python/3.9.13 Darwin/21.6.0 botocore/1.29.62
But awscli2 --version returns:
2.2.0
AWS CLI v2 command: docker run -i --rm -v /Users/tomkealy/.aws:/root/.aws -v /Users/tomkealy/my-folder:/aws amazon/aws-cli
aws-cli/2.9.20 Python/3.9.11 Linux/5.10.47-linuxkit docker/x86_64.amzn.2 prompt/off
which aws returns /Users/tomkealy/opt/anaconda3/bin/aws
and aws --version returns
aws-cli/1.27.62 Python/3.9.13 Darwin/21.6.0 botocore/1.29.62
How do I fix this so that yawsso finds the version 2 of the aws-cli?
I have tried to uninstall aws via conda and brew. To no success.
I figured it out by uninstalling awscli
pip uninstall awscli -y
which meant that which aws now pointed to
/usr/local/bin/aws
but aws --version now errored:
-bash: /Users/tomkealy/opt/anaconda3/bin/aws: No such file or directory
and I fixed THAT with
export PATH=$PATH:$HOME/aws-cli
now which aws gives
/usr/local/bin/aws
and aws --version prints
aws-cli/2.9.20 Python/3.11.1 Darwin/21.6.0 source/x86_64 prompt/off

Why is the aws cli not found on amazonlinux2 ami?

The AmazonLinux2 AMI I am using for my Docker hosts does not appear to have the AWS CLI installed. The log has an error from the user data script that tries to run an aws command:
/var/lib/cloud/instance/scripts/part-001: line 7: aws: command not found
Then I connected with SSH to the instance for a sanity check, and aws is definitely not found:
[ec2-user#ip-X-X-X-X ~]$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
[ec2-user#ip-X-X-X-X ~]$ aws --version
-bash: aws: command not found
I thought the AWS CLI was installed by default on all AmazonLinux AMIs? I don't remember ever having to install it myself before.
This article even says that the CLI v1 is installed by default on AmazonLinux2:
AWS Docs Link
So how is it possible that it's not found on this stock AMI? Do only some of the AmazonLinux2 AMIs have the CLI pre-installed? For reference, I am using this AMI:
amzn2-ami-minimal-hvm-2.0.20200917.0-x86_64-ebs (ami-0a6993b2978bd23cb)
From this post on AWS forum:
Minimal has a smaller set of packages installed by default. For example, a lot of AWS specific packages are installed on the default for easy integration to other AWS services. The minimal do not have these installed. This gives a much lower footprint for those who are not directly interacting with other AWS services, or who want to cherry-pick which ones they install.
If you want awscli, you can install it:
sudo yum install -y awscli
to install the latest version of the awscli (v2) see this doc
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

docker login unknown flag: --no-include-email

I'm trying (and failing) to authenticate docker to AWS ECR. I've generated my AWS token via the AWS CLI aws ecr get-login command and have been provided with the following:
docker login -u AWS -p <token> --no-include-email https://***.dkr.ecr.eu-central-1.amazonaws.com.
However, when I execute this command, I get unknown flag : --no-include-email.
I've done much reading on the subject which all seem to say it's a version problem as --no-include-email flag was introduced to replace the deprecated -e none flag. I'm running the following versions:
Docker version 18.03.0-ce, build 0520e24302,
AWS CLI 1.16.88,
Python 3.6.0, and
Windows 7 x64.
I've even double checked my initial AWS CLI installation by installing AWS CLI via pip and checking for an upgraded version with pip install --user --upgrade awscli.
I initially had the error described docker login unknown shorthand flag: 'e'.
Everything is up-to-date.
It might be worth noting here that I am authenticating with AWS via a standard credentials file
[default]
aws_access_key_id = ***
aws_secret_access_key = ***
What am I missing?
The --no-include-email flag is an AWS CLI flag, not a docker flag. To use it, add it to your get-login call:
$ aws ecr get-login --no-include-email
docker login -u AWS -p ey...V9 https://123456789.dkr.ecr.us-east-1.amazonaws.com
Try comparing with and without the --no-include-email flag. You'll notice that using --no-include-email omits the -e none part of the output. You can copy/paste the given command to login to docker. To save you the copy/paste, login with one command:
eval "$(aws ecr get-login --no-include-email)"
This worked for me with AWS CLI version 2:
docker login --username AWS -p $(aws ecr get-login-password) <aws-ecr-url>

AWS Docker deployment fails with error: unknown shorthand flag: 'e' in -e and no basic auth credentials [duplicate]

I just updated my docker version and found out that command
aws ecr get-login
is not working anymore. Got error:
unknown shorthand flag: 'e' in -e`. Seems that docker doesn't support -e flag anymore.
Is there a way to fix this?
Installed versions:
aws-cli/1.11.111 Python/2.7.10 Darwin/16.6.0 botocore/1.5.74
Docker version 17.06.0-ce-rc5, build b7e4173
add this to your call
--no-include-email
here is the new valid syntax :
aws ecr get-login ${normal_params_here} --no-include-email
aws ecr get-login --region us-east-1 --no-include-email # for example
This new option is available in AWS CLI as of version 1.11.91 released on 05/23/2017 ... issue this to upgrade :
pip install --upgrade awscli
see details here
https://github.com/docker/for-mac/issues/1762
https://github.com/aws/aws-cli/issues/1926
to quote :
"You should have received an email notification from Amazon around May 23 2017 about the new --no-include-email flag on aws ecr get-login for compatibility with [Docker] 17.06.0"
For example after I issue following
aws ecr get-login --region us-east-1 --no-include-email
it shows me following output
docker login -u AWS -p foobarZUFtSzg4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VLOVc0NytQVkJUSWtsNnhrd0Jobm9nZ1MwUkYyc2xNb1F6S08zZHhva24zN0dSS1hoOXhSbG85RVlWOHZLRzVzbjdhbnhpby9EL3ZDbHFXWTlLRGVwOGxMK0NhR3lpbDRHZ3JwWmtWampaaExzQ1cyTWk0L3NXUTEyV0ZCR0JnOSIsImRhdGFrZXkiOiJBUUVCQUhod20wWWFJU0plUnRKbTVuMUc2dXFlZWtYdW9YWFBlNVVGY2U5UnE4LzE0d0FBQUg0d2ZBWUpLb1pJaHZjTkFRY0dvRzh3YlFJQkFEQm9CZ2txaGtpRzl3MEJCd0V3SGdZSllJWklBV1VEQkFFdU1CRUVESnpKWXZhbXBFRkFSVUx5bUFJQkVJQTcwZk1ZUlU4bG9RVnRwMWJJUHRoZktTOFMzZVpZNS8rT0orL0RmSjZXNVpiK0p0TURXZmZ5Rm9vc0gzMDFVWS9OQ1lzb2hWM1FER2E3NmZ3PSIsInZlcnNpb24iOiIyIiwidHlwZSI6IkRBVEFfS0VZIiwiZXhwaXJhdGlvbiI6MTU2NDkxNTYyOH0= https://092412696969.dkr.ecr.us-east-1.amazonaws.com
so to complete docker login to aws repository copy N paste above back into same terminal, as per ...
docker login -u AWS -p foobarZUFtSzg4SDBUa0lDSEpTNUQ5M3pDVDhHNi9jS2s3SExhQWpheEVMWTlmY0pNWlphOEN5M2hJTUFoMDlJczd0anVoRk9CKzE1ODdBdmQ1ZzRNR3pKa1lMZ2NTOGo4Mk1sZGlwdDRjQlJyOERvaDFiaEt6TWRlVHkzalA2Um5RSTBNNW5qRW9WL1ZlaEhxMTV4bjl5aXQrV1NXMnp1NWNwek1JQWVxRjd0YWhZWkxxYmdRVjdldE9LQUY3dW5OWFFSM20vY0x4L1ZKWW9BZzlNM0wrQy8vdENEQXRXMFpvTTNrVXNxTHg4MEFQQXJRV08yZ1BRb0VLcHo1ZE1sc1JLS25hWit2eGVzODdlUFZ3OS9tT29BV0pEUzBSWUx0ellsUUVKNUpadXlkbXlnL2owL2N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WJJUHRoZktTOFMzZVpZNS8rT0orL0RmSjZXNVpiK0p0TURXZmZ5Rm9vc0gzMDFVWS9OQ1lzb2hWM1FER2E3NmZ3PSIsInZlcnNpb24iOiIyIiwidHlwZSI6IkRBVEFfS0VZIiwiZXhwaXJhdGlvbiI6MTU2NDkxNTYyOH0= https://092412696969.dkr.ecr.us-east-1.amazonaws.com
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /home/pualu/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
now you are logged into the aws docker repository
if for some reason you can't upgrade awscli version, you can do a little string manipulation to make it work for you with sed.
for example:
$(aws ecr get-login --region eu-central-1 | sed -e 's/-e none//g')
this will drop the -e flag that is not supported and you should be able to login.
I had the same issue however following Scott Stensland's answer did not solve it.
In case it will happen to someone else, dropping '-e none' from the command solved the issue.
Run login statement.
aws ecr get-login --region us-west-2
Then, remove the flag and value -e none from the resulting statement.
So, what you run would look like...
docker login -u AWS -p <long password hash> https://<image ID>.dkr.ecr.us-west-2.amazonaws.com
If you prefer to avoid refreshing your authentication token manually with aws ecr get-login, you can install the Amazon ECR credential helper instead. The credential helper will take care of retrieving and updating tokens automatically so you don't need to refresh it yourself. Packages are available for Debian (Buster or newer), Ubuntu (19.10 or newer), Amazon Linux 2, Mac OS (via Homebrew), and a few other operating systems, or you can download binary releases from the releases page.
C:\WINDOWS\system32>docker rm -f $(docker ps -qa)
unknown shorthand flag: 'q' in -qa)
See 'docker rm --help'.
If the issue is caused in Windows OS then try to run the command in PowerShell with Admin Privileges
It worked for me.

Unable to push docker images into AWS ECR from Windows 10

When I try to execute this command:
> aws ecr get-login --no-include-email --region us-east-1
I keep getting the error message:
> Unknown options: --no-include-email
I followed the instructions here: http://docs.aws.amazon.com/cli/latest/userguide/installing.html
to update my aws cli to the latest version:
> pip install awscli --upgrade --user
but the problem persists.
I am completely blocked, as there's no other way that I can use to push my docker images to Amazon ECR.
My environment is the following:
Windows 10 Pro
Version 1607
64 bits
aws-cli/1.11.89 Python/2.7.9 Windows/8 botocore/1.5.52
Docker version 17.06.0-ce, build 02c1d87
I found a workaround which was to just use the regular command:
> ecr get-login --region us-east-1
And then I removed the part:
>...-e none...
from the docker login command that was generated and ran it like that and I was able to login into my aws ecr repositories.
If you get rid of the email option, you might have a return line including a ''-e none'' that you dont want you can sed it
aws ecr get-login --youroptions | sed 's/\-e none//g'