「Amazon Container Services」からコマンドをコピーした後、aws ecr が「非 TTY デバイスから対話型ログインを実行できません」と表示します 質問する

「Amazon Container Services」からコマンドをコピーした後、aws ecr が「非 TTY デバイスから対話型ログインを実行できません」と表示します 質問する

ubuntu18.04AWSのマシンにAmazon ECRのDockerイメージをセットアップしようとしていますview push commandsAmazon Container Services Amazon コンテナ サービスのプッシュ コマンドを表示する

dockerすでに設定しておりubuntu18.04、出力はdocker -v以下のとおりです。

ubuntu@ip-172-31-0-143:~$ docker -v
Docker version 19.03.7, build 7141c199a2

ubuntu18.04のaws cliでamazon container servicesが提供するコマンドを実行すると、「エラー: 非TTYデバイスから対話型ログインを実行できません」というエラーが発生します。

私が使用しているコマンドは

aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 8233251134332.dkr.ecr.us-east-2.amazonaws.com/gatling-lots

awscliの設定に成功し、詳細を確認できるようになりました。aws s3 ls

詳細なエラーログはこちら

ubuntu@ip-172-31-0-143:~$ aws ecr get-login-password --region us-   
east-2 | docker login --username AWS --password-stdin 
823443336.dkr.ecr.us-west-2.amazonaws.com/gatling-lots
usage: aws [options] <command> <subcommand> [<subcommand> ...]      
[parameters]
 To see help text, you can run:

aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument operation: Invalid choice, valid choices are:

 batch-check-layer-availability           | batch-delete-image                      
 batch-get-image                          | complete-layer-upload                   
create-repository                        | delete-lifecycle-policy                 
delete-repository                        | delete-repository-policy                
 describe-images                          | describe-repositories                   
 get-authorization-token                  | get-download-url-for-layer              
 get-lifecycle-policy                     | get-lifecycle-policy-preview            
 get-repository-policy                    | initiate-layer-upload                   
 list-images                              | put-image                               
 put-lifecycle-policy                     | set-repository-policy                   
 start-lifecycle-policy-preview           | upload-layer-part                       
 get-login                                | help                                    
 Error: Cannot perform an interactive login from a non TTY device

出力

ubuntu@ip-172-31-0-143:~$ (aws ecr get-login --no-include-email  --region us-east-2)

docker login -u AWS -p 

MzQxL2c0Yks4RjVxeDg9IiwidmVyc2lvbiI6IjIiLCJ0eXBlIjoiREFUQV9LRVkiLCJleHBpcmF0aW9uIjoxNTgzNjgzNDY5fQ== https://825251119036.dkr.ecr.us- east-2.amazonaws.com

ベストアンサー1

問題は aws ではなく docker です。解決策は、docker で -p パラメータを使用し、aws ログイン呼び出しを次のように -p パラメータにラップすることです。

docker login -u AWS -p $(aws ecr get-login-password --region the-region-you-are-in) xxxxxxxxx.dkr.ecr.the-region-you-are-in.amazonaws.com

これには AWS CLI バージョン 2 が必要です。

おすすめ記事