Push docker image to amazon ecs repository

前端 未结 5 2280
春和景丽
春和景丽 2020-12-12 17:39

Im new to AWS. I want to set up a private docker repository on an AWS ECS container instance. I created a repository named name. The example push commands shown

相关标签:
5条回答
  • 2020-12-12 18:17

    I tried the following steps and confirmed working for me:

    1. aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin xxxxxxxx.dkr.ecr.us-west-2.amazonaws.com

    2. aws ecr create-repository --repository-name test

    3. docker build -t test .

    4. docker tag test:latest xxxxxxxx.dkr.ecr.us-west-2.amazonaws.com/test:latest

    5. docker push xxxxxxxx.dkr.ecr.us-west-2.amazonaws.com/test:latest

    0 讨论(0)
  • 2020-12-12 18:17

    Addition to the above answer, I came across here today, as the login command change with aws-cli v2, posting as an answer might help others. as aws-cli v1 login command no longer work.

    V1
    $(aws ecr get-login --no-include-email)
    
    

    To push image to ECR using aws-cli v2 you need

    aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 123456789.dkr.ecr.us-west-2.amazonaws.com
    

    Then you are okay to build and push

    docker build -t myrepo .
    docker tag myrepo:latest 123456789.dkr.ecr.us-west-2.amazonaws.com/myrepo
    docker push 123456789.dkr.ecr.us-west-2.amazonaws.com/myrepot
    
    

    Typically One image per registry is a clean approach, that why AWS increase image per repository and repository per region from 1000 to 10,000.

    0 讨论(0)
  • 2020-12-12 18:19

    No need to create a repo per image, just restructure naming:

    docker build -t foo .
    docker tag foo ####.dkr.ecr.us-west-2.amazonaws.com/name:foo_v0.23.1
    docker push ####.dkr.ecr.us-west-2.amazonaws.com/name:foo_v0.23.1
    
    0 讨论(0)
  • 2020-12-12 18:22

    The EC2 Container Registry requires an image Repository to be setup for each image "name" or "namespace/name" you want to publish to the registry.

    You can publish any :tags you want in each Repository though (The default limit is 100 tags).

    I haven't seen anywhere in the AWS documentation that specifically states the repository -> image name mapping but it's implied by Creating a Repository - Section 6d in the ECR User Guide

    The Docker Image spec includes it's definition of a Repository

    Repository

    A collection of tags grouped under a common prefix (the name component before :). For example, in an image tagged with the name my-app:3.1.4, my-app is the Repository component of the name. A repository name is made up of slash-separated name components, optionally prefixed by a DNS hostname. The hostname must comply with standard DNS rules, but may not contain _ characters. If a hostname is present, it may optionally be followed by a port number in the format :8080. Name components may contain lowercase characters, digits, and separators. A separator is defined as a period, one or two underscores, or one or more dashes. A name component may not start or end with a separator.

    0 讨论(0)
  • 2020-12-12 18:31

    You need to create a repository for each image name, but the image name can be of the form "mycompanyname/helloworld". So you create mycompanyname/app1, mycompanyname/app2, etc

    aws ecr create-repository --repository-name mycompanyname/helloworld
    aws ecr create-repository --repository-name mycompanyname/app1
    aws ecr create-repository --repository-name mycompanyname/app2
    docker tag helloworld:latest xxxxxxxx.dkr.ecr.us-west-2.amazonaws.com/mycompanyname/helloworld:latest
    docker push xxxxxxxx.dkr.ecr.us-west-2.amazonaws.com/mycompanyname/helloworld:latest
    docker tag app1:latest xxxxxxxx.dkr.ecr.us-west-2.amazonaws.com/mycompanyname/app1:latest
    docker push xxxxxxxx.dkr.ecr.us-west-2.amazonaws.com/mycompanyname/app1:latest
    
    0 讨论(0)
提交回复
热议问题