15

I am trying to download a Docker image from AWS and following the instructions at AWS I'm running:

(Get-ECRLoginCommand).Password | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com

However, I'm getting the following error:

Get-ECRLoginCommand : The term 'Get-ECRLoginCommand' is not recognized as the name of a cmdlet, function, script file, or operable program.

How can I fix this error? I assume I need to install the module.

sashoalm
  • 75,001
  • 122
  • 434
  • 781

4 Answers4

23

After some searching, I realised I had omitted installing ECR when installing AWSTools. I had used these 2 commands:

Install-Module -Name AWS.Tools.Installer -Force
Install-AWSToolsModule AWS.Tools.EC2,AWS.Tools.S3 -CleanUp

So I installed it with:

Install-AWSToolsModule AWS.Tools.ECR

After that it worked.

sashoalm
  • 75,001
  • 122
  • 434
  • 781
19

In my case, running this command on the AWS CLI instead of the AWS tool for Windows PowerShell worked.

aws ecr get-login-password --region [your region] | docker login --username AWS --password-stdin [your aws_account_id].dkr.ecr.[your region].amazonaws.com
mitsu
  • 383
  • 2
  • 11
2

I was also facing this issue. And there were serveral things that need to be done for the command to work.

The Permission ecr:GetAuthorizationToken is required for the IAM-User.

The modules need to be installed

Install-Module -Name AWS.Tools.Common 
Install-Module -Name AWS.Tools.ECR

After that it is required to set the credentials, and tell the Credential-Manager that those are to be used as default.

Set-AWSCredential `
             -AccessKey <KeyName> `
             -SecretKey <Key> `
             -StoreAs <Profile>

Initialize-AWSDefaultConfiguration -ProfileName <ProfileName> -Region eu-central-1

(Documentation is scattered, which makes following the guide tricky for me, but here are the sources Credential specification, Creating Access Key )

dCSeven
  • 815
  • 8
  • 18
1

To solve this issue use this format command instead the one suggested on the ECR View Push Command

aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com

replacing the red fields by your correct data.

Also check that your aws.config file is in the correct format.

You can find more info here:

Working format

Correct config file formatting

32cupo
  • 850
  • 5
  • 18
  • 36