LoginSignup
16
4

More than 3 years have passed since last update.

ECRにdockerをプッシュする時に、credentialsのエラーが出たときの対処

Posted at

AWS ECRにdockerをプッシュする時、テンプレートのコピペだと上手くいかないところがあったのでメモ。

環境

aws-cli/2.0.6
AWSのプロファイル設定済み

エラー内容

テンプレートをそのままコピペすると以下のコマンドになります。

$ aws ecr get-login-password --region [region] | docker login --username AWS --password-stdin [account].dkr.ecr.[region].amazonaws.com/[repositry name]

が、上記のコマンドを実行しても、以下のようなエラーが出てしまいます。

Unable to locate credentials. You can configure credentials by running "aws configure".
Error: Cannot perform an interactive login from a non TTY device

解決方法

AWSのcredentialは設定済みだったのですが、そのプロファイル名を自分で指定してあげる必要がありました。そのためには、コマンド前半の--region [region]--profile [profile name]に変更する必要がありました。

$ aws ecr get-login-password --profile [profile name] | docker login --username AWS --password-stdin [account].dkr.ecr.[region].amazonaws.com/[repositry name]

これで、リポジトリにプッシュできるようになりました。([profile name]には、自分で設定しているプロファイル名を入れます)

16
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
4