1
votes

I am new to Docker, trying to follow the official get started guide.

When I want to login, I type docker login, then I type my login and my password. It outputs "Login Succeeded". But when I want to push the image with docker push drazik/get-started:part1, it outputs "unauthorized: authentication required".

I am absolutely sure that my login/password are good. But there is something weird : I can type whatever I want as username and password, docker login always outputs "login suceeded".

My docker version is "1.13.1, build 27e468e/1.13.1".

Does somebody can figure out what's wrong ? Thank you very much.

1
What is the login you use when entering docker login ? - Alexandre Fenyo

1 Answers

-1
votes

Note that the authorization token, generated when you log in, is saved into ~/.docker/config.json, and read from this same file when you push an image.

So, here are the only ways such a situation can happen:

1-

You are using an account on DockerHub with the login name: mylogin (anything but drazik)

You create a local image this way:

docker build -t drazik/get-started:part1 .

You log in Docker this way:

% docker login
Username: mylogin
Password: ********

Then you push the image this way:

% docker push drazik/get-started:part1
The push refers to a repository [docker.io/drazik/get-started:part1]
5bef08742407: Preparing
unauthorized: authentication required

Thus, this means you are not using the account drazik to log in, but another one.

2-

you do not share the same local account to log in, create the image and push the image (for instance, you log in to DockerHub as local user root , you create the image as root, but you push the image as a simple user).

Therefore, the authorization token is saved into ~root/.docker/config.json but docker push tries to read it from ~user/.docker/config.json