Skip to content

Instantly share code, notes, and snippets.

@jaygiang
Created May 23, 2018 21:36
Show Gist options
  • Save jaygiang/b629ba4d230faa2da5110267eead0d95 to your computer and use it in GitHub Desktop.
Save jaygiang/b629ba4d230faa2da5110267eead0d95 to your computer and use it in GitHub Desktop.
Setting up AWS ECR
  1. Log into AWS Console
  2. Search AWS Service ECS
  3. Select Repositories from the left menu under "Amazon ECR"
  4. Select Create repository
  5. Retrieve the docker login command that you can use to authenticate your Docker client to your registry
aws ecr get-login --no-include-email --region us-west-2
  1. Run the docker login command that was returned in the previous step.
Invoke-Expression -Command (aws ecr get-login --no-include-email --region us-west-2)
  1. Build your Docker image using the following command. You can skip this step if your image is already built:
docker build -t YOUR-IMAGE-NAME .
  1. After the build completes, tag your image so you can push the image to this repository.
docker tag YOUR-IMAGE-NAME:TAG-VERSION YOUR-AWS-REPO-URI/YOUR-IMAGE-NAME:TAG-VERSION
  1. Run the following command to push this image to your newly created AWS repository:
docker push YOUR-AWS-REPO-URI/YOUR-IMAGE-NAME:TAG-VERSION
  1. SSH into your EC2
  2. (Optional) Search for ECR Repositories
aws ecr describe-repositories --region us-west-2
  1. (Optional) Describe image within a ECR Repository
aws ecr describe-images --repository-name amazonlinux
  1. Docker pull ECR image to your EC2
docker pull AWS-ACCOUNT-ID.dkr.ecr.us-west-2.amazonaws.com/YOUR-IMAGE-NAME:TAG-VERSION
  1. Run pulled docker image
docker run -d --env-file .env --name NEW-IMAGE-NAME -p "80:80" NAME-OF-DOCKER-IMAGE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment