c. Create a Docker Repository

In this step, you create a Docker repository and upload a container image to this repository.

Create the Docker Repository

Use the AWS CLI create a Docker repository on Amazon ECR, the AWS managed container registry.

aws ecr create-repository --repository-name carla-av-demo

Fetch and Upload a Docker Image

Fetch the image from the web, then import it to your newly created ECR repository.

  1. Fetch the docker credentials.

    REGION=$(curl --silent http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/[a-z]$//')
    $(aws ecr get-login --no-include-email --region ${REGION})
  2. Import and tag the image.

    # get the repository URI
    ECR_REPOSITORY_URI=$(aws ecr describe-repositories --repository-names carla-av-demo --output text --query 'repositories[0].[repositoryUri]')
    curl https://s3.amazonaws.com/av-workshop/carla-demo.tar -o carla-demo.tar
    docker load -i carla-demo.tar
    docker tag carla-demo:latest $ECR_REPOSITORY_URI
  3. Push the image to the ECR repository.

    docker push $ECR_REPOSITORY_URI:latest