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

  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
  5. Tag the existing image and push to the ECR:
    docker image ls
    docker tag bad666cafe
    docker push