Skip to content

Instantly share code, notes, and snippets.

@mvsusp
Last active July 25, 2018 04:08
Show Gist options
  • Save mvsusp/07610f9cfecbec13fb2b7c77a2e843c4 to your computer and use it in GitHub Desktop.
Save mvsusp/07610f9cfecbec13fb2b7c77a2e843c4 to your computer and use it in GitHub Desktop.
How to push a Docker image to AWS ECS
#!/usr/bin/env bash
IMAGE_NAME=sagemaker-tf-serving
REGION=$(aws configure get region)
ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
# If the ECS repository doesn't exist, creates it.
aws ecr create-repository --repository-name ${IMAGE_NAME} > /dev/null 2>&1
# ECR requires the image name to be in this format:
REPOSITORY_NAME=${ACCOUNT}.dkr.ecr.${REGION}.amazonaws.com/${IMAGE_NAME}:latest
# Tags the image with the expect ECR format
docker tag ${IMAGE_NAME} ${REPOSITORY_NAME}
# Allows docker access to ECR
$(aws ecr get-login --no-include-email)
# pushes the image to ECR
docker push ${REPOSITORY_NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment