Login Issue with Docker to ECR in eu-south-2 Region

0

Hello,

I'm encountering a problem when attempting to log in to Amazon ECR using Docker, specifically in the eu-south-2 region. Here's the command I used and the error message I received:

❯ aws ecr get-login-password --region eu-south-2 | docker login --username AWS --password-stdin ACCOUNT_ID.dkr.ecr.eu-south-2.amazonaws.com
Error saving credentials: error storing credentials - err: exit status 1, out: `error storing credentials - err: exit status 1, out: `The stub received bad data.``

When I try the same command but with the eu-central-1 region, the login is successful:

❯ aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin ACCOUNT_ID.dkr.ecr.eu-central-1.amazonaws.com
Login Succeeded

The account is enabled for the eu-south-2 region, and the AWS CLI user has the AmazonEC2ContainerRegistryFullAccess policy. Both the AWS CLI and Docker Desktop are updated. I would appreciate any advice or solutions to resolve this issue. Thank you for your help.

Muriel
asked 13 days ago99 views
5 Answers
1

The issue you're facing with the login process in the eu-south-2 region may be due to a known issue with the Docker credential helper. A workaround for this problem is to modify the .docker/config.json file and remove the "credsStore" key.

Steps to Resolve the Issue

  1. Open the .docker/config.json file, which is located in your user's home directory (e.g., C:\Users\YourUsername\.docker\config.json on Windows or ~/.docker/config.json on macOS/Linux).

  2. Locate the "credsStore" key and delete it. The file should look similar to this:

{
  "auths": {
    "https://index.docker.io/v1/": {
      "auth": "your-base64-encoded-credentials"
    }
  }
}
  1. Save the changes to the config.json file.

  2. Now, try the login command again:

aws ecr get-login-password --region eu-south-2 | docker login --username AWS --password-stdin ACCOUNT_ID.dkr.ecr.eu-south-2.amazonaws.com

This should now work, and you should see the "Login Succeeded" message.

The root cause of the issue seems to be related to the Docker credential helper, which is responsible for storing and retrieving Docker login credentials. In some cases, the credential helper may not work correctly, leading to the "The stub received bad data" error.

If you continue to experience issues, you may need to explore other troubleshooting steps, such as checking your AWS permissions, verifying the Docker version, or contacting AWS support for further assistance.

profile pictureAWS
answered 13 days ago
profile picture
EXPERT
reviewed 12 days ago
0

Thank Henrique Santana for your guidance on resolving the Docker login issue. It was quite helpful. Your suggested solution worked partially for me. However, I encountered another challenge with the Docker credential helper, and I had to rename the docker-credential-wincred.exe file to make it work fully.

I have now managed to log in successfully, but I'm receiving a new warning about storing the password unencrypted in my config.json file.

WARNING! Your password will be stored unencrypted in C:\Users\YourUsername\.docker\config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

Although I am concerned about the security implications of this warning, I am relieved that the login finally succeeded. I'm concerned about the security implications of this setup. Could you suggest a more secure alternative or guide me through configuring a credential helper to avoid storing my password in an unencrypted form?

Thank you in advance for your assistance.

Muriel
answered 13 days ago
profile picture
EXPERT
reviewed 12 days ago
  • Thanks for the feedback, and yes, I also have seen some people saying about to rename the .exe file to make it work but I was unsure since most of my search results were pointing to the shared steps mostly.

    Regarding the unencrypted, this is a general message from docker client. You can use the ECR Credential Helper to setup this. Please find more info on Authenticating Amazon ECR Repositories for Docker CLI with Credential Helper blog post.

    Feel free to mark my answer as accepted if you think that it was useful. Thanks!

0

Try executing aws ecr get-login-password --region eu-south-2 and see if you recieve an error.. Im going to assume this is where its failing

profile picture
EXPERT
answered 13 days ago
profile picture
EXPERT
reviewed 13 days ago
0

Thank you for your suggestion, Gary. I tried running aws ecr get-login-password --region eu-south-2 as you recommended, and I am able to obtain the token successfully. However, when I store the token in a variable $token and execute:

echo $token | docker login --username AWS --password-stdin ACCOUNT_ID.dkr.ecr.eu-south-2.amazonaws.com

I encounter the same error as when running the full command. It seems the issue occurs at the point of storing the credentials by Docker, rather than generating the token itself. Any further insights or suggestions would be greatly appreciated!

Muriel
answered 13 days ago
0

I’ve observed an interesting discrepancy that might be affecting Docker's default credential management. Specifically, the login token for AWS's eu-central-1 region is 2,952 characters long, whereas the token for the eu-south-2 region extends to 3,904 characters. This significant difference in token size may be causing issues with Docker’s credential handling mechanisms.

Could this larger token size be the reason behind the credential management failures I'm experiencing? I'd appreciate any insights or suggestions on how to address this potential issue.

Thanks in advance for your help!

Muriel
answered 13 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions