Docker Login Succeeded, but Push Failed with `denied: Your authorization token has expired. Reauthenticate and try again.` on push
I was wrapping up work on a Docker image and decided to push it to an Amazon ECR (Elastic Container Registry) private repository. To log in, I used the following command:
aws ecr get-login-password --region ***** --profile ****** | docker login --username AWS --password-stdin *****.dkr.ecr.*****.amazonaws.com
The command executed successfully, basically login succeeded:
WARNING! Your password will be stored unencrypted in /home/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
However, as you expected 😊, when I attempted to push the image, I got: 😱
denied: Your authorization token has expired. Reauthenticate and try again.
Alas, the simple fix was that, as a Linux user, I hadn’t added sudo
to the docker login
command. This small oversight ended up costing me about three hours to figure out. 😅
aws ecr get-login-password --region ***** --profile ****** | sudo docker login --username AWS --password-stdin *****.dkr.ecr.*****.amazonaws.com
Thank you for reading—hope this fix resolves your issue! 🙌