...
If you are managing a lot of repositories, instead of using environment variables, it might be simpler to create login profiles in your AWS CLI and reference those to login to the registry
aws --profile myapp ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <<repositoryUri>>
and/or use the Amazon ECR Credential Helper
https://github.com/awslabs/amazon-ecr-credential-helper
Pushing an image tag into a repository
...