Software Development

How to fix the "unauthorized: incorrect username or password" error when running docker login?

KI Asked by Kimberly Wright · 10-06-2023
0 upvotes 12,489 views 0 comments
The question

I keep getting an authentication error when trying to pull or push images to Docker Hub. The error specifically says: Error response from daemon: get unauthorized: incorrect username or password. I am certain my credentials are correct because I can log into the web interface. Is there an issue with using my email address instead of my username, or does Docker now require a Personal Access Token (PAT) for CLI authentication?

3 answers

0
SA
Answered on 11-06-2023

The most common cause for this error is using your email address as the username in the CLI. Docker Hub's web portal accepts both, but the docker login command strictly requires your Docker ID (username). Additionally, for enhanced security, Docker has moved toward Personal Access Tokens (PAT). If you have Multi-Factor Authentication (MFA) enabled, your standard account password will not work on the command line at all. You must go to your Docker Hub Account Settings, navigate to Security, and generate a new Access Token. Use that token as your password when prompted by the terminal. This is currently the most reliable method to bypass credential mismatch errors and secure your CI/CD pipelines. 

0
BR
Answered on 15-07-2023

I tried using my username instead of email, but I still get the same error. Could it be related to how my credentials are being stored in the config.json file? 

DA 16-07-2023

Brian, that’s a very valid point. Sometimes the ~/.docker/config.json file gets corrupted or holds stale credentials from a previous session. Try running docker logout first to clear the cache, then delete the config.json file if the issue persists before trying to log in again. Also, make sure you aren't running sudo docker login if your user is already in the docker group, as this can create permission conflicts between the root and user-level credential stores.

0
LI
Answered on 20-11-2023

You definitely need to use a Personal Access Token instead of your password. Most modern registries are moving away from basic password auth for security reasons. 

KI 22-11-2023

I agree with Lisa. Switching to a PAT fixed this for my entire team. It’s also much safer because you can revoke the token specifically for that machine without changing your main password.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

World globe icon Country: India

Book Free Session