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]
には、自分で設定しているプロファイル名を入れます)