Skip to content

ECR managing images in AWS

Adam Brown edited this page Jun 8, 2022 · 6 revisions

Prerequisite steps

Required for for interacting with AWS ECR repository, ie pushing, pulling, deleting images

  1. Check your terminal session is logged into the correct AWS profile, aws configure list.
  2. Next log into ECR via AWS passing the login details to Docker, run:

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

You should see a following response say you are authorised and logged in. Now you're ready to push, pull, delete images from our repo.

List all images stored in ECR

  1. Make sure you are logged into the correct AWS profile.
  2. In terminal run aws ecr list-images --repository-name <name here>.

For example, for the hale-platform-dev namespace you would type aws ecr list-images --repository-name jotw-content-devs/hale-platform-dev-ecr

Push an image to ECR

Here we use our dev namespace as an example.

  1. Build the image on your local machine. This can be done either via running make build or manually building using docker build <name> .. Either way, when you type docker images you should see the image in the list.

  2. Tag the image.

docker tag <local image name> 754256621582.dkr.ecr.eu-west-2.amazonaws.com/jotw-content-devs/hale-platform-dev-ecr:<image name>

  1. Push the image

docker push 754256621582.dkr.ecr.eu-west-2.amazonaws.com/jotw-content-devs/hale-platform-dev-ecr:<image name in ECR>

Note: when you tag the image, in step 2, that is when you are giving the image it's "name" in ECR. You can choose to name the image the same name as on your local machine or you can give it a new name. Remember the name must match the name inside the k8s manifest file where you specify what image you are pulling.

Remove an image

Run

aws ecr batch-delete-image --repository-name jotw-content-devs/hale-platform-dev-ecr --image-ids imageTag=hale-platform-wordpress imageTag=hale-platform-nginx

Note: imageTag is the you choose in step 2.

Clone this wiki locally