The problem is that it doesn’t work with powershell, resulting with the following error:
Error response from daemon: login attempt to https://AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/v2/
failed with status: 400 Bad Request
It works fine with CMD, but not Powershell. After searching around for solution, I found that the issue is that the first section of the script that gets the password, appends a new line to it, which causes the second part of the script to fail. I searched for a way to strip that new line from the first section with no success. This does not work:
According the documentation in Powershell the command should be (Get-ECRLoginCommand).Password | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com and requires AWSPowershell to be installed.
Nope, just tried it using AWS Powershell Tools and I get the same error. It looks like no matter what you do that first section before the pipe appends the new-line. This doesn’t work: (Get-ECRLoginCommand).Password | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
but this does: $password = (Get-ECRLoginCommand).Password docker login --username AWS --password $password aws_account_id.dkr.ecr.region.amazonaws.com
But then I’m back to square one with the insecure warning: WARNING! Using --password via the CLI is insecure. Use --password-stdin
After wasting hours on this, I’ve finally found a solution. As I mentioned earlier, this works fine in CMD, so I figured I’d try to run CMD from PowerShell. Turns out you can do it like this: cmd.exe \c "your command"