LoginSignup
0
0

More than 5 years have passed since last update.

Amazon ECRでDockerイメージを管理する

Posted at

はじめに

触る機会があったのでメモ代わりに手順をまとめます

Amazon ECRとは?

Docker コンテナイメージを簡単に保存、管理、デプロイすることができるサービスです。

AWS CLI のインストール

awsコマンドを使える状態にします。

$ curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
$ sudo python get-pip.py
$ sudo pip install awscli

設定

aws configureコマンドを使って設定します。

$ aws configure
AWS Access Key ID [None]: *****
AWS Secret Access Key [None]: *****
Default region name [None]: us-east-1
Default output format [None]: json

リポジトリ作成

CloudFormationでリポジトリを作成します。

Resources: 
  WebContainerRepository:
    Type: AWS::ECR::Repository
    Properties:
      RepositoryName: *****

DockerイメージのPush

Dockerクライアントの認証に使用するログインコマンドを取得します。

$(aws ecr get-login --no-include-email --region us-east-1)

Dockerイメージの作成

docker build -t ***** .

DockerイメージのPush

docker push *****.dkr.ecr.us-east-1.amazonaws.com/sample:latest

DockerイメージのPull

docker pull *****.dkr.ecr.us-east-1.amazonaws.com/sample:latest

ライフサイクルポリシー

ライフサイクルポリシー
ライフサイクルポリシーを設定することで不要になったイメージを有効期限切れにしてくれます。
イメージを頻繁にPushするような環境であれば設定した方がいいかもしれません。

0
0
0

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
0
0