Create Elastic Container Registry (ECR) and Upload Images

Amazon Elastic Container Registry (ECR) is a fully managed container registry offering high-performance hosting, so you can reliably deploy application images and artifacts anywhere.


Ensure AWS Credentials are properly configured before running any aws cli commands. This ensures that all aws commands will work as expected. For further information, see AWS Credentials Configuration Documentation.

Create Elastic Container Registry

Use the following to create an ECR repository:

aws ecr create-repository --repository-name xxxxxxxxxxxx

    "repository": {
        "repositoryArn": "arn:aws:ecr:us-west-2:xxxxxxxxxxxx:repository/dl1_batch_training",
        "registryId": "xxxxxxxxxxxx",
        "repositoryName": "dl1_batch_training",
        "repositoryUri": "",
        "createdAt": 1661376423.0,
        "imageTagMutability": "MUTABLE",
        "imageScanningConfiguration": {
            "scanOnPush": false
        "encryptionConfiguration": {
            "encryptionType": "AES256"

Build and Push Image to ECR

  1. Create a file to manage image configuration:




Update xxxx to match your AWS Account Number


Update xxxx to the name of your image

  1. Create a file to build and tag an image based on the properties file:


source ./

echo "Building base container ..."

docker build -t ${registry}/${image_name}:${image_tag} -f ./Dockerfile .
  1. Run to build and tag the Docker image:

  1. Create a file to log into the generated ECR and push the built image to the registry based on the properties file:

source ./

echo "Logging into ECR"
aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${registry}

echo "Pushing to ECR"
docker push ${registry}/${image_name}:${image_tag}

echo "Done..."
  1. Run to log into the ECR and push the built image: