0
0

More than 5 years have passed since last update.

Using Amazon Elastic Container Registry (ECR) as soon as possible anyway.

Last updated at Posted at 2019-05-03

Create an image you want.

$ mkdir docker-php && cd docker-php
$ vim index.php
index.php
<?php echo "Hello, world."; ?>
$ vim Dockerfile
Dockerfile
FROM php:7-apache
COPY index.php /var/www/html/
$ docker build -t php .
$ docker images 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
php                 latest              cba780f28f8b        52 seconds ago      378MB
php                 7-apache            1dffbbe4a5d3        3 weeks ago         378MB

Install AWS CLI to use ECR.

$ curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
$ sudo python get-pip.py
$ sudo pip install awscli
$ rm -rf get-pip.py
$ aws --version
aws-cli/1.16.150 Python/2.7.13 Darwin/17.5.0 botocore/1.12.140

Create IAM (If you don't have it.)

  1. Sign in or create an account on AWS.
  2. Create IAM user
  3. Choose "User" at left side.
  4. Enter name that you like and check "access via program".
  5. Attache "AmazonEC2ContainerRegistryFullAccess"
  6. Skip tagging.
  7. Confirm your information.
  8. Done

Apply your information using AWS CLI.

$ aws configure
AWS Access Key ID [None]: ****************** [Enter you Access Key ID]
AWS Secret Access Key [None]: ****************** [Enter your Secret Access Key]
Default region name [None]: ap-northeast-1
Default output format [None]: json

You can check your info this command.

$ aws configure list

Create repository on ECR

Access to ECR -> Amazon ECR -> Repositories.

1.png

Enter "php" (in here) as repository name.

2.png

Done.

Push to ECR from local image.

Log in to AWS

$ (aws ecr get-login --no-include-email --region ap-northeast-1)
docker login -u AWS -p ....
$ docker login -u AWS -p ....
...
Login Succeeded

push to your ECR repository.

Use your id instead of ************.

$ docker tag php:latest ************.dkr.ecr.ap-northeast-1.amazonaws.com/php:latest
$ docker push ************.dkr.ecr.ap-northeast-1.amazonaws.com/php:latest

If you'd like to update your image, tagging and push again as same tag.

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