in my case, after spending some time investigating, the issue was with the keychain of mac OS for some reason.
so depending on where the password gets stored (refer to this link for reference) , the config file ~/.docker/config.json can either look like one of the following:
1. If no keychain used , the password will be stored directly in the file ,
example :
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "base64-encode-of-your-credentials"
}
}
}
2. If a key chain is used then the credentials will not be saved in the file and the credsStore will be mentioned in the file ,so will look something like this :
{
"credsStore" : "osxkeychain",
"auths" : {
"https://index.docker.io/v1/" : {
}
}
}
In my case a cred store was being used and apparently there was something wrong with even it when I docker logout and docker login again , in which case 2 different solutions have worked for me:
1. Edit the config file and remove the "credsStore" : "osxkeychain" element and also add the “auth” element along with the base64 encoding of your creds from the format username:password , this way you are telling docker I am directly using the credentials from the file and no key store used , of course this method is less secure.
2. I opened the keychain access in my mac ( by searching for keychain access in the spotlight search) , then inside there I searcher for docker to see the credentials , upon opening it and ticking show password I found that the value was empty (not sure why) , so I manually put it there and clicked saved changes .
and voila after applying any of above solutions , the docker push command worked normally.