Push images to ECR

Pre-requisites:

  • You need the aws cli configured
  • You need to configure your credentials using aws configure
  • You need you ECR endpoint which you can get from the AWS console

Step 1 – Get login access

aws ecr get-login –no-include-email –region eu-central-1

aws ecr get-login –no-include-email –region eu-central-1

Step 2 – Copy and paste the login output:

docker login -u AWS -p dhNGlmbDZ5S0g2QWZXdUZQTnd5cEpnYUowcnRpV3JzemFsVFlzWTZ0MjBKOVh2Q21WZUh2UkcrQnRhdm40c2JxSVJVK1p5Q05tVGRJRzJPZVRXejVsZkdyOHUzcTJscmU2UEpMbTQyb01ZSWwrS0lxNXR2RzRvR0RXUjlmOUFjMlMrbNzU2fQ== https://419222136312.dkr.ecr.eu-central-1.amazonaws.com
WARNING! Using –password via the CLI is insecure. Use –password-stdin.
WARNING! Your password will be stored unencrypted in /home/ec2-user/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

Step 3 – List your images

$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wordpress latest bfcb59709143 4 days ago 550MB
mysql latest e646c6533b0b 5 days ago 546MB
httpd 2.4 d5995e280a0e 5 days ago 138MB
amazon/amazon-ecs-agent latest 6258e300d0a3 2 weeks ago 61.5MB
amazon/amazon-ecs-pause 0.1.0 cd1e683df418 2 weeks ago 954kB

Step 4 – Tag your image:

docker tag wordpress:latest 419222136312.dkr.ecr.eu-central-1.amazonaws.com/imraans-repo:wordpress-ecr

PLEASE NOTE: TAG IS SPECIFIED AT THE END OF THE LINE AFTER THE REPO NAME

Step 5 : Push your image:

docker push 419222136312.dkr.ecr.eu-central-1.amazonaws.com/imraans-repo:wordpress-ecr
The push refers to repository [419222136312.dkr.ecr.eu-central-1.amazonaws.com/imraans-repo]
76c5b970e97d: Pushed
651c4bbf328c: Pushed
b41fb8d2abee: Pushed
b379bf5940f6: Pushed
18cd1ca0b33a: Pushed
0efafbb89fb8: Pushed
9e85943e46a8: Pushed
a1a6e38ba805: Pushed
c8ae3aa75745: Pushed
909be82f7875: Pushed
fb68a1ee61ab: Pushed
2e6b88d65db1: Pushed
24344b18b968: Pushed
3649852bd029: Pushed
ce7d9d7fcbb5: Pushed
e5fd6412b327: Pushed
405456085900: Pushed
c50749333c3d: Pushed
5239f515d394: Pushed
9f7e0d511596: Pushed
346fddbbb0ff: Pushed
wordpress-ecr: digest: sha256:0436b1fad846858ee25b7ac115688326de33394c457a495102dbc0dfd63f32e1 size: 4709

PLEASE NOTE, That if your image is not tagged it wont push the image and give you the following error:

tag does not exist:

No token or token has expired.