Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login command says "The handle is invalid" after inputting username #15272

Closed
eppsilon opened this issue Aug 3, 2015 · 35 comments
Closed

Login command says "The handle is invalid" after inputting username #15272

eppsilon opened this issue Aug 3, 2015 · 35 comments

Comments

@eppsilon
Copy link

eppsilon commented Aug 3, 2015

To reproduce:

docker login [repo]
Username: [type username, hit Enter]
The handle is invalid.

But this command DOES work:

docker login --username [username] --password [password] --email [email] [repo]
WARNING: login credentials saved in [blah]
Login Succeeded

So the problem might be something to do with reading from stdin?

Vague, uninformed theory: could this ReadPassword issue be related?

docker version:

Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): windows/amd64
Server version: 1.7.0
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 0baf609
OS/Arch (server): linux/amd64

docker info:

Containers: 3
Images: 76
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 82
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.0.5-boot2docker
Operating System: Boot2Docker 1.7.0 (TCL 6.3); master : 7960f90 - Thu Jun 18 18:31:45 UTC 2015
CPUs: 8
Total Memory: 1.955 GiB
Name: boot2docker
ID: 3NB7:ICRC:QASK:SOLS:X5SQ:FWNP:LSL7:LGPP:FNE3:SO5H:MKPB:INIS
Debug mode (server): true
File Descriptors: 26
Goroutines: 47
System Time: 2015-08-03T21:45:53.563558526Z
EventsListeners: 0
Init SHA1:
Init Path: /usr/local/bin/docker
Docker Root Dir: /mnt/sda1/var/lib/docker

uname -a:

MINGW64_NT-6.3 mdnbepps 2.1.0(0.288/5/3) 2015-06-28 18:57 x86_64 Msys
@noooonee
Copy link

I got the same issue, and the long one is working, thanks.

@crramirez
Copy link

Same. My configuration Windows 10 x64, Docker Tools, Docker-engine 1.8.1

@thaJeztah
Copy link
Member

Wonder if this is the same issue as #12469 (comment)

/cc @jhowardmsft @swernli

@gmanfunky
Copy link

@thaJeztah , not quite the same issue. but I suspect both have to do with the way that docker is using GO to do terminal stuff.

Regular Windows 7 cmd.exe window can control a docker run -it ubuntu bash just fine.

But the "no tty" problem with docker run -it shows up when running in a terminal like MSYS2 MinTTY and can be worked around by starting it under a console eumulator, like winpty or conemu project included in some shells.

But the docker login is a different sort of failure. With docker 1.8.x on windows, docker login fails to get usernames and passwords by prompt. It doesn't matter which terminal environment it is running under. At least example has a work-around with providing arguments on the command line.

Windows 10 made some further terminal changes that may complicate analysis of these bugs.

@Crispy1975
Copy link

I see the same behaviour from the Git Bash shell on Windows 10.

@hschaeidt
Copy link

Having the same issue here.

As workaround I did

docker-machine ssh <your_machine>
docker login <your_private_repo>

And then copied the persisted credentials in ~/.docker/config.json to my host machine (windows).

docker pull <your_private_repo>/<some_image>
Works as expected afterwards.

@sai-li
Copy link

sai-li commented Nov 13, 2015

Thanks @hschaeidt. My windows worked with your idea.

@lowenna
Copy link
Member

lowenna commented Nov 13, 2015

Please can you try the latest docker.exe from master.dockerproject.org. I have made recent changes. If you still see the invalid handle error, I would like to investigate further as this is not expected now.

@npiv
Copy link

npiv commented Nov 21, 2015

Got exactly the same with the latest one @jhowardmsft

@lowenna
Copy link
Member

lowenna commented Nov 21, 2015

Can you provide docker version, your client OS details and what environment you are running the login from - cmd/powershell/mingw+version/Cygwin etc @npiv

@rick-maclean
Copy link

I downloaded the most recent docker toolbox and was trying to run this from Docker Quickstart bash window (C:\Users\username\AppData\Local\Programs\Git\bin\bash.exe)
Windows 7 Professional

I also tried it from the bash the normal way I launch that at had the same problem.

@lowenna
Copy link
Member

lowenna commented Dec 4, 2015

@rick-maclean Same request for info as per above please... Particularly docker version

@rick-maclean
Copy link

I ran this from the docker quickstart terminal
$ docker version
Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): windows/amd64
Server version: 1.9.1
Server API version: 1.21
Go version (server): go1.4.3
Git commit (server): a34a1d5
OS/Arch (server): linux/amd64

next I tried to run docker login
$docker login
Username (rickmaclean):

pressing return does not work.

HOWEVER.......when I created the machine manually from git-bash
using the cmd prompt instructions located here:
set PATH=%PATH%;.......
docker-machine create --driver virtualbox my-default
THEN ssh to the machine
I can run docker login just fine.

ALSO: I was able to start the default machine that is created by the quickstart terminal
$docker-machine start default
$docker-machine ssh default
and then
$docker login
works properly that way too.

@lowenna
Copy link
Member

lowenna commented Dec 5, 2015

So that's why. The bug wasn't fixed until 1.10 on the Windows client. 1.7 definitely had the bug. by running ssh, you're running a Linux binary which doesn't have the bug.

@thaJeztah
Copy link
Member

@jhowardmsft we're considering a 1.9.2 release, think we should cherry-pick that fix into that release? Do you remember which PR fixed this?

@lowenna
Copy link
Member

lowenna commented Dec 5, 2015

#17738

@thaJeztah
Copy link
Member

Ah, that fix should already be in 1.9.1, so installing the 1.9.1 version should work

@CalebEverett
Copy link

I'm still getting the same issue with 1.9.1 on Windows 8.1 Pro.

$ docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      windows/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64


$ docker login --username=calebeverett --email=caleb@calebeverett.io

The handle is invalid.


$ docker login --username calebeverett --password [password] --email calebeverett/docker-whale

Error response from daemon: invalid registry endpoint https://calebeverett/docker-whale/v0/: unable to ping registry endpoint https://calebeverett/docker-whale/v0/
v2 ping attempt failed with error: Get https://calebeverett/docker-whale/v2/: dial tcp 198.105.244.228:443: connection refused
 v1 ping attempt failed with error: Get https://calebeverett/docker-whale/v1/_ping: dial tcp 198.105.244.228:443: connection refused. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry calebeverett` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/calebeverett/ca.crt

@lowenna
Copy link
Member

lowenna commented Dec 5, 2015

I'm struggling to repro this. I'm using the same version of docker client and server. Have tried the invalid handle repro from cmd, powershell and git v2.6.2 bash. Note the "forbidden by administrative rules" error is expected as I don't have valid credentials for registry-win-tp3.docker.io.

C:\users\jhoward\downloads>docker-1.9.1.exe login --username=jhowardmsft --email=jhoward@Microsoft.com
Password:
Error response from daemon: Unexpected status code [403] : <html><body><h1>403 Forbidden</h1>
Request forbidden by administrative rules.
</body></html>

C:\users\jhoward\downloads>powershell
Windows PowerShell
Copyright (C) 2015 Microsoft Corporation. All rights reserved.

C:\users\jhoward\downloads> .\docker-1.9.1.exe login --username=jhoward --email=jhoward@microsoft.com
Password:
Error response from daemon: Unexpected status code [403] : <html><body><h1>403 Forbidden</h1>
Request forbidden by administrative rules.
</body></html>
C:\users\jhoward\downloads> sh
sh-4.3$ /c/users/jhoward/downloads/docker-1.9.1.exe login --username=jhoward --email=jhoward@microsoft.com
Password:
Error response from daemon: Unexpected status code [403] : <html><body><h1>403 Forbidden</h1>
Request forbidden by administrative rules.
</body></html>
sh-4.3$ /c/users/jhoward/downloads/docker-1.9.1.exe version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      windows/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:20:08 UTC 2015
 OS/Arch:      linux/amd64
sh-4.3$ bash --version
GNU bash, version 4.3.42(3)-release (x86_64-pc-msys)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
sh-4.3$

@lowenna
Copy link
Member

lowenna commented Dec 5, 2015

I should add, I can also successfully logon to a DTR using the same client:

Password:
WARNING: login credentials saved in C:\Users\jhoward.docker\config.json
Login Succeeded
sh-4.3$

@CalebEverett
Copy link

Thank you, I was able to get the response you did by going back to the default terminal. I had changed the shortcut based on this issue to get a more user friendly terminal.

Could you provide any other info on how to resolve the registry issue? I was following along with the tutorial and got the aforementioned error at step 8.

I tried this fix but got this error:

Error response from daemon: invalid registry endpoint https://index/docker.io/v1
/: Get https://index/docker.io/v1/_ping: dial tcp 198.105.244.228:443: connectio
n refused. If this private registry supports only HTTP or HTTPS with an unknown
CA certificate, please add `--insecure-registry index` to the daemon's arguments
. In the case of HTTPS, if you have access to the registry's CA certificate, no
need for the flag; simply place the CA certificate at /etc/docker/certs.d/index/
ca.crt

@lowenna
Copy link
Member

lowenna commented Dec 6, 2015

I'm no registry expert by any means. If it's a DTR without the certs set (such as the one I logged onto in my last comment above), I simply added --insecure-registry myhost.blankedout.azure.com in the daemon start parameters.

@CalebEverett
Copy link

I was just trying to push an image to Docker Hub.

@lowenna
Copy link
Member

lowenna commented Dec 6, 2015

You won't be able to push Windows images to docker hub. Only to a DTR as of TP4.

@CalebEverett
Copy link

Ok, now I feel better. So is this tutorial for the future or a thing of the past?

https://docs.docker.com/windows/step_six/

@lowenna
Copy link
Member

lowenna commented Dec 6, 2015

Hmm, it should still work from a Windows client pointing to a Linux daemon. I haven't got time to check if does actually work though right now. A workaround if it does fail is to do the push from a Linux client (eg by ssh onto the Linux box)

@CalebEverett
Copy link

Ok, thanks for the responses. I'll see if I can figure it out on the other issue.

@tyagian
Copy link

tyagian commented Jan 18, 2016

There is temporary solution working fine for me:
Just change config.jason file to

{
"auths": {
"https://index.docker.io/v1/": {
"auth": "",
"email": ""
},
"https://registry-win-tp3.docker.io/v1/": {
"auth": "",
"email": ""
}
}
}

Docker 403 forbidden error
http://networkengg.com/docker-login-failed-on-windows-403-forbidden-error

@tcrockett1138
Copy link

It looks like this is specific to the password field..?? Username is accepted in prompt or long form. email is accepted in prompt or long form. Password seems to be where it chokes.

But it worked for me using winpty.

$ docker login
Username: tcrockett
The handle is invalid.

$ docker login --username tcrockett
The handle is invalid.

$ docker login --username tcrockett --password xxxxxx
Email: xxx@yyy.com
WARNING: login credentials saved in C:\Users\tcrockett\.docker\config.json
Login Succeeded

$ winpty docker login --username tcrockett
Password:
WARNING: login credentials saved in C:\Users\tcrockett\.docker\config.json
Login Succeeded


$ docker version
Client:
 Version:      1.10.2
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   c3959b1
 Built:        Mon Feb 22 22:37:33 2016
 OS/Arch:      windows/amd64

Server:
 Version:      1.10.2
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   c3959b1
 Built:        Mon Feb 22 22:37:33 2016
 OS/Arch:      linux/amd64

@rmartins01
Copy link

thaks tcrockett1138 !!!

@rivaros
Copy link

rivaros commented May 3, 2016

Not working for me with latest version of git (1.11.1). I tried in git MinGW64
and mintty.exe. Did not try in command prompt, since I would never use it.

Still get "The handle is invalid".

Also I have the tty/non-tty error when trying to docker exec -ti <container_name> /bin/bash

Any thoughts?

docker version
Client:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Tue Apr 26 23:44:17 2016
 OS/Arch:      windows/amd64

Server:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Wed Apr 27 00:34:20 2016
 OS/Arch:      linux/amd64

@rivaros
Copy link

rivaros commented May 3, 2016

Also having problem with latest docker-compose (1.7.0) and private registries. Even when I am logged in
with the tricky docker login --username user --password pass repo_url, and try to up some docker-compose.yml, it fails telling that authorization failed. Though I can manually do docker pull on these repositories successfully. Also on OSX docker-compose works fine, and considers the authentication status. On Windows not.

@lowenna
Copy link
Member

lowenna commented May 24, 2016

Resolving this "by design". This is because mintty's stdin is not a console. This is well documented at https://mintty.github.io/ under Compatibility at the top, and discussed in this thread: mintty/mintty#56

You see the same thing in linux if you do cat | docker login - you will get "inapprioriate ioctl for device".

I will submit a PR which gives a better error on Windows, but there's very little that can be done short of getting a fix in mintty, although it sounds like this is by design for them.

The better solution is to use the native Windows console on Windows - cmd, PowerShell, or LXSS. You also don't see this using sh from Git for Windows 2.7/2.8

@lowenna lowenna closed this as completed May 24, 2016
@lowenna
Copy link
Member

lowenna commented May 24, 2016

Also more info at https://code.google.com/archive/p/mintty/issues/56

@Devendrabhat
Copy link

Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
This error came when i tried to do login. Please someone help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests