Docker always says unauthorized: authentication required when pushing an image - docker

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.

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

Related

Pushing docker image to gitlab fails: unauthorized

I'm trying to push an image to my gitlab registry which i previously built with success.
docker login registry.gitlab.com
I give the credentials and it returns me a "Login Succeeded"
Then, as always, i do a
docker push registry.gitlab.com/username/registry/base:latest
And it ends with
unauthorized: authentication required
i already tried to
docker logout registry.gitlab.com
and login again.
The process can be found here, it's pretty simple
link to github/gitlabhq
I'm used to do it like that, first time i face the issue, don't understand
Any help appreciated !
Ensure that your account has read/write access to the registry you are trying to access. What you might need to do is to create a new Access Token as there is a difference between API/Access tokens and your "normal" user password. Use this access token as described in the documentation (https://github.com/gitlabhq/gitlabhq/blob/master/doc/user/packages/container_registry/index.md#authenticate-with-the-container-registry)
docker login registry.example.com -u <username> -p <token>
The token can be created by going to Edit Profile -> Access Tokens -> Select Scopes -> Ticking off 'Read registry' & 'Write registry'
The Gitlab support told me this is due to a native limitation of the token duration.
You cannot customize this duration in Saas mode.
So pushing large image results in auto logout.

Gitlab test out with Docker: ' You have signed up successfully. However, we could not sign you in because your account is awaiting approval...'

I have set up gitlab locally on ubuntu laptop per some help from this post. My set up is 100% exact to per that post. When I ran docker-compose up and visited localhost:54321 I was shown a screen to 'update my password'. I entered a new password then got taken to the sign in page where I clicked to sign up with a new account. I entered my name, email and password and hit register. I then saw this message:
I'm confused since I'm hosting gitlab locally via docker.Who is my gitlab administrator?!
How can I register on a locally hosted gitlab instance via docker? My ultimate goal is just a hello world - I'd like to explore the gitlab interface and see what the tool is all about.
The initial admin user for the GitLab CE is root.
In the GitLab Docker container path /etc/gitlab, there will be a file called "initial_root_password". Cat the content and you can got the initial password of the user root
Steps:
Assume the docker container name is gitlab_web_1
Go to the Docker container: docker exec -ti gitlab_web_1 /bin/bash
List item: cat /etc/gitlab/initial_root_password
Once you login with the user root successfully, you can try to manage the user account, and you can also use your own account to login.
Based on This Page
https://forum.gitlab.com/t/after-gitlab-ce-installation-on-ubuntu/32896
Username and Password default Administrator after Install Gitlab-ce:
Username: root
Password: 5iveL!fe
When opening the web interface after first running the container, you are prompted to 'change password'. Enter a password then on the next page enter username 'root' and the password you just created. I had to rerun the container and first empty everything in the set up directories. Emptied everything in data/, logs/ and config/ and then docker-compose up. That allowed me to login

Can login into docker-registry but not push image (github)

So I want to use the docker registry from GitHub.
I do the flowing:
docker login docker.pkg.github.com --username username
docker build . --tag docker.pkg.github.com/user-name/repo/IMAGENAME:snapshot
docker push docker.pkg.github.com/user-name/repo/IMAGENAME:snapshot
Note that the repository is private and not mine but I got write access to it.
When I go to packages tab I can also see the instructions on how to get started and I follow them(kind of, I tag the docker image in one go).
But when I run the 3 commands at the top I get the following output(push command fails):
unauthorized: Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:packages'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
When I visit the site referenced there is nothing there only unrelated tokens.
Any ideas what I could try or what may cause this...?
You need to use an API Token to log in like shown in the docs. Log in via password is not possible.
https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages
You must use a personal access token.

Docker hello-world: authentication error

I'm just getting started with docker. I'm following the instructions specified here https://docs.docker.com/windows/step_one/
I installed docker (1.10.2) on windows 10 & ran docker run hello-world . But, I'm getting an authentication error while the tutorial doesn't mentioned anything about it.
Here's the message I received.
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Authentication is required: Get https://registry-1.docker.io/v2/library/hello-world/manifests/latest: unauthorized: incorrect username or password.
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.
I searched google & here, but couldn't find anything similar to this error message.
Thanks!
Please run docker login at first time when you run any other docker commands.
You can log into any public or private repository for which you have credentials. When you log in, the command stores encoded credentials in $HOME/.docker/config.json on Linux or%USERPROFILE%/.docker/config.json on Windows.
If you login through your emailId it does not works.
On windows login using your docker hub id.
You can access by your username.
Probably it can happen if you were logged in before, by console or by kitematic.
You can try docker logout if you want use docker without auth.
In this case Authentication is required: shouldn't appear again.
I have solved this issue in macOS Mojave (version : 10.14.3)
docker login
Login with your username not email id then its working fine.
On macOS you need to login from the commandline using
docker login
Also you must use your username and not your email
on ubuntu:
docker login
so if you don't know your username password, you probably haven't created one.
what you should do, is go and create an id on docker
visit: official docker webpage
just like any other github accout ,they will ask you for the username, provide one and they will authenticate same as github, once done , put your email and password. verify it and you are now good to go.
ok! now coming to the point...
if you were facing the problem like the problem statement ,
just do
docker login
enter username and password, that you just provided .
you will be displayed ,"LOGIN succeeded"
now run this command
docker run hello-world
beware of the dash '-' sign , i myself stuck with this issue, and you are done.
thanks:)
run docker login to execute any other docker commands. or just logout if you want to use public hubs docker logout
For worked trying docker logout and then docker login with the proper credentials
For those who logged in via their email address associated with their account during the Docker desktop installation process - this problem seems to occur because the terminal has also stored those credentials, but for some reason it only accepts login's via your actual username.
If you go to DockerHub you should see it in the upper right corner.
Try running docker login with that username, and you should be all set!
docker login
# username from dockerhub
# the same password
Setting my vNAT for docker dns server to 8.8.8.8 resolved my issue on windows just try might help thanks

docker push - access not authorized

I am trying to push an image to docker hub.
I created an account "kaffeekaethe" and created a public repository "reservierung".
I build the image "kaffeekaethe/reservierung" (no typos, I double checked that).
Afterwards I logged into docker hub and tried to push the image, but I am alwasy getting the error "access to the requested resource is not authorized". Everyone else who had this problem wasn't logged in prior to the push command, and that was the only solution that I've found. Is there any other reason for this error?

Resources