Docker login problems [closed] - docker

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Created username password on hub.docker.com but I still get authentication error when I run docker run hello-world, and even when I run "docker login" then enter my credentials ....but it shows a success message when I do
docker login -u <myusername> -p <mypassword> https://hub.docker.com
but even after that if I try to run
docker run hello-world
I get the same error:
"error response from daemon: login attempt to https://registry-1.docker.io/v2/ failed with status: 401 Unauthorized"

Try logging out first with docker logout
I often find that this will at least allow me to pull images when there is some authentication issue.

docker logout
docker login
DONOT put email address as “username” when login from CLI. Instead USE username of you account

A few things going wrong here. First the login command shouldn't specify a url. Instead you specify a registry. And for hub, you don't even include that:
docker login -u <myusername> -p <mypassword>
Next, the hello-world image doesn't require any authentication. If you have bad credentials setup, you can logout:
docker logout
If you still see issues after that, the most likely cause is a proxy on your network intercepting the request, and it's not docker Hub giving the 401 error, but instead it's the proxy server. You can configure docker to use a proxy by following both of the following:
Configure the client: https://docs.docker.com/network/proxy/
Configure the engine: https://docs.docker.com/config/daemon/systemd/#httphttps-proxy

Try this command first:
docker logout https://hub.docker.com
You should get an output like:
Removing login credentials...
Then try to login.

I had similar problem, in my case, my solution was, that I need to input the password via STDIN method as below:
first create a file with the content is your docker password, e.g. in ~/my_password.txt
Then login using this method:
cat ~/my_password.txt | docker login --username [your_username_here] --password-stdin
Remember, your username is not your email.

Test docker login With modify Docker General Config (macOS High Sierra 10.13.3 & Docker Engine:18.09.2)
1. With GUI Account login
1.1 With General -> Securely store Docker logins in macOS keychain (checked)
docker login failed
1.2 With General -> Securely store Docker logins in macOS keychain (unchecked)
docker login successed
it will Authenticating with existing credentials.
2. With GUI Account logout
2.1 With General -> Securely store Docker logins in macOS keychain (checked)
docker login failed
2.2 With General -> Securely store Docker logins in macOS keychain (unchecked)
docker login successed
SO,
unchecked General->Securely store Docker logins in macOS keychain, it solved my docker login failed problem

Related

Can not login to docker with docker toolbox

I'm absolutely new to the docker and I want to push my docker image to docker hub. I'm running windows 7, so I have installed docker toolbox.
So, in power shell when I type:
docker login it asks for a login and a password, but when I hit enter, it gives me no information if login was successful.
But when I try docker push <image name>
I get an error: denied: requested access to the resource is denied
P.S.
If I enter incorrect login/password on docker login, it gives me the corresponding message
Solved! For anyone who may faced the following issue - the problem was that windows username was written not with latin letters. Creating another user with latin name fixed that problem.

Login to Docker Hub by command line

I have read some Docker tutorials and I see this command line:
docker login -u LOGIN -p PASSWORD
But the registry server URL is never set.
How does the docker command know the registry URL? What is the URL for Docker Hub Registry? I have tried this:
docker login -u LOGIN -p PASSWORD cloud.docker.com
but it does not work.
If you want to login to the default Docker Hub repository, simply use:
docker login
or more specifically:
docker login registry-1.docker.io
You can also login using a Docker Hub Access Token: https://docs.docker.com/docker-hub/access-tokens.
To do that:
Access your Docker Hub account.
Click on your avatar (on the page top right side).
Click on Account and Settings.
Click on Security (on the page left side in the middle).
And then click on New Access Token button.
Give a token description, define the token permissions and click on Generate.
Copy and save your token.
Then log in with your new token. Type docker login -u <your-username> on your terminal and paste your Access Token when requested by the password.
docker login -u <your-username>
You may need to use a specific registry version, for me this worked.
docker login registry-1.docker.io/v1
In my case docker daemon is not running, so I just restarted it and re-executed same command. It worked!!
While login you may encountered with permission denied issues, in that case first give bellow command:
sudo chmod 666 /var/run/docker.sock
then use:
docker login

Docker login without specifing password in cli

The problem is docker login creds take password directly in command option which is insecure. Commands get logged in event log for process creation or powershell or bash can be configured to log all of the script text. This can lead to creds getting leaked. So My question is how can i pass the secret to docker login without passing it directly in command line. I can't find any option in docker login that takes a file which has creds.
cat ~/my_password.txt | docker login --username foo --password-stdin
In one of the latest Teamcity you can create connection where you specify password (which is then invisible) and then using Build features you can use this connection to login before build process begins.

Docker: How to authenticate for docker push?

Hi i'm trying docker push
[docker-simple-httpserver]# docker push myregistry/simplehttpserver:latest
The push refers to a repository [myregistry/simplehttpserver] (len: 1)
Sending image list
FATA[0000] Error: Status 403 trying to push repository simplehttpserver: "{\"error\": \"Unauthorized updating repository images\"}"
is there a way for me to specify the username and password on docker push command?
I would think they keep passwords off the command line for security reasons.
The way to do it is to login first then push.
https://docs.docker.com/mac/step_six/
$ docker login --username=maryatdocker --email=mary#docker.com
Password:
WARNING: login credentials saved in C:\Users\sven\.docker\config.json
Login Succeeded
Then push
$ docker push maryatdocker/docker-whale
The push refers to a repository [maryatdocker/docker-whale] (len: 1)
7d9495d03763: Image already exists
c81071adeeb5: Image successfully pushed
Typically you would specify your password using the interactive docker login then do a docker push.
For a non-interactive login, you can use the -u and -p flags:
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
The Travis CI docs for docker builds gives an example of how to automate a docker login.
See docker login for more details.
As far as I know you have to use docker login. The credentials will be stored in /home/user/.docker/config.json for following docker pushes.
If you are after automation the command expect will be interesting for you.
In case, one needs to login to the custom docker repo, use below:
docker login -u ${USERNAME} -p ${PASSWORD} ${DOCKER_REPOSITORY}
The accepted answer works perfectly fine! However, if you are trying to access a private registry, you may have to consider making the following change request.
docker login -u ${user_name} ${private_registry_domain}
Provide password, when it prompt for the same.
docker login --username=YOUR_DOCKERHUB_USERNAME
In this case your dockerhub password will be an access token.
Refer: https://docs.docker.com/docker-hub/access-tokens/#create-an-access-token
If you are tagging image with IP then login docker registry with IP, If you are tagging image with domain-name then login docker with domain-name, Somehow docker doesn't like mixing IP and domain and failing.
Not direct answer to the question, but you can first login and then do docker push.
docker login -unice-username
After which it will prompt for a password. After successful login you can do docker push.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
use "sudo docker login" not "docker login" as one uses the root account and the other uses your personal.
Personally I create the repo on dockers website prior to the upload.

Having error pushing docker container on Bluemix

When I tried to push my Java container on Bluemix using the command:
docker push registry.ng.bluemix.net/shru19
It asked me for username, password and email so I put my Bluemix user id and password but it didn't accept it.
Can you suggest what is it asking?
The IBM Container registry uses a login token which will be refreshed when you log in. When you receive a login prompt when performing a docker push, that should be an indication that the token is invalid and needs to be refreshed.
Run cf ic login to get the token refreshed and then re-run your docker push command.

Resources