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
已提问 1 个月前133 查看次数
5 回答
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
已回答 1 个月前
profile picture
专家
已审核 1 个月前
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
已回答 1 个月前
profile picture
专家
已审核 1 个月前
  • 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
专家
已回答 1 个月前
profile picture
专家
已审核 1 个月前
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
已回答 1 个月前
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
已回答 1 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则

相关内容