Published: 12. 11. 2020   Category: GNU/Linux

Copy docker images from Docker Hub to AWS Elastic Container Registy

Expected that your AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY is set or you have a proper profile in ~/.aws/credentials to be able to use awscli. I am expecting that your ECR repository exists, it is accessible by hostname account-id.dkr.ecr.region.amazonaws.com.

  1. First download images locally: docker pull myorg/repository
  2. Check images are here: docker images ls
  3. Get authorization token: aws ecr get-authorization-token --region=us-east-2
  4. Once the token exists, provide temporary login for docker:
    aws ecr get-login-password --region=us-east-2 | \
    docker login --username AWS --password-stdin XXX.dkr.ecr.us-east-2.amazonaws.com
    
  5. Tag the existing image and push to the ECR:
    docker image ls
    docker tag bad666cafe XXX.dkr.ecr.us-east-2.amazonaws.com/repository
    docker push XXX.dkr.ecr.us-east-2.amazonaws.com/repository