【AWS】AWS CLIを使用して、ECRにDocker imageをアップロードする
記事の内容
ECSやEKSに使用するDocker ImageをECRにaws cliを使って登録する方法をご紹介いたします。
ECRリポジトリを作成する
ECRリポジトリを作成
test-repoという名前でリポジトリを作成
$ aws ecr create-repository --repository-name test-repo
ECRリポジトリを一覧で確認する
$ aws ecr describe-repositories
ECRにImageをpushする
以下の4コマンドはAWS consoleのECR画面の 【プッシュコマンドの表示】
から確認できる
ログイン
$ aws ecr get-login-password | docker login --username AWS --password-stdin https://<aws_account_id>.dkr.ecr.<region>.amazonaws.com
Login Succeeded
Dockerイメージをbuild
$ docker build -t test-repo .
Dockerイメージにtagを付与
$ docker tag test-repo:latest <aws_account_id>.dkr.ecr.<region>.amazonaws.com/test-repo:latest
リポジトリにpush
$ docker push <aws_account_id>.dkr.ecr.<region>.amazonaws.com/test-repo:latest
確認
AWS CLI
$ aws ecr describe-images --repository-name test-repo
コンソール画面から
AWSコンソールからも確認が可能(省略)