Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does "docker login" fail in Docker Quickstart Terminal but work from within the default machine?

I've installed Docker Toolbox in Windows 8.1 and have been following the installation tutorial. When getting to the step where you create and push your own image, I got this error when I attempted to run docker login ... .

### VIA Docker Quickstart Terminal
### docker login --username=myuser --password="mypass" [email protected]
time="2015-11-17T03:20:58.160803558Z" level=debug msg="Calling POST /v1.21/auth" 
time="2015-11-17T03:20:58.160838971Z" level=info msg="POST /v1.21/auth" 
time="2015-11-17T03:20:58.169033324Z" level=debug msg="hostDir: /etc/docker/certs.d/https:/registry-win-tp3.docker.io/v1" 
time="2015-11-17T03:20:58.169071565Z" level=debug msg="pinging registry endpoint https://registry-win-tp3.docker.io/v1/" 
time="2015-11-17T03:20:58.169084660Z" level=debug msg="attempting v1 ping for registry endpoint https://registry-win-tp3.docker.io/v1/" 
time="2015-11-17T03:20:58.898542338Z" level=debug msg="Error unmarshalling the _ping PingResult: invalid character '<' looking for beginning of value" 
time="2015-11-17T03:20:58.898803841Z" level=debug msg="PingResult.Version: \"\"" 
time="2015-11-17T03:20:58.898818084Z" level=debug msg="Registry standalone header: ''" 
time="2015-11-17T03:20:58.898836197Z" level=debug msg="PingResult.Standalone: true" 
time="2015-11-17T03:20:58.898853685Z" level=debug msg="attempting v1 login to registry endpoint https://registry-win-tp3.docker.io/v1/" 
time="2015-11-17T03:20:59.478756938Z" level=error msg="Handler for POST /v1.21/auth returned error: Unexpected status code [403] : <html><body><h1>403 Forbidden</h1>\nRequest forbidden by administrative rules.\n</body></html>\n\n" 
time="2015-11-17T03:20:59.478815334Z" level=error msg="HTTP Error" err="Unexpected status code [403] : <html><body><h1>403 Forbidden</h1>\nRequest forbidden by administrative rules.\n</body></html>\n\n" statusCode=500 

Trying to solve the issue, I tried running docker login ... from within the Docker default VM. And there it works!

### VIA default virtual machine (192.168.99.100)
### docker login --username=myuser --password="mypass" [email protected] https://index.docker.io/v1/
time="2015-11-17T03:20:46.053333255Z" level=debug msg="Calling POST /v1.21/auth" 
time="2015-11-17T03:20:46.053404176Z" level=info msg="POST /v1.21/auth" 
time="2015-11-17T03:20:46.082796012Z" level=debug msg="hostDir: /etc/docker/certs.d/https:/index.docker.io/v1" 
time="2015-11-17T03:20:46.082930763Z" level=debug msg="pinging registry endpoint https://index.docker.io/v1/" 
time="2015-11-17T03:20:46.082946790Z" level=debug msg="attempting v1 ping for registry endpoint https://index.docker.io/v1/" 
time="2015-11-17T03:20:46.082959103Z" level=debug msg="attempting v1 login to registry endpoint https://index.docker.io/v1/" 

I notice that they're using two different URLs and that the first one encounters a parsing error. The credentials are obviously correct since they work from within the VM, unless the two domains don't share users. Are the URLs or the response being mangled by MINGW64?

like image 582
Nejuf Avatar asked Nov 17 '15 03:11

Nejuf


1 Answers

Update February 2016

PR 19891 "Enable cross-platforms login to Registry" is supposed to fixed the issue

Use a daemon-defined Registry URL for docker login.

This allows a Windows client interacting with a Linux daemon to properly use the default Registry endpoint instead of the Windows specific one.

It is in commit 19eaa71 (maybe for docker 1.10?)


This is reported both in docker/docker issue 15612 and docker/docker issue 18019

After some analysis of the source code I’ve detected that we have different registry URLs for Windows and UNIX.

  • Windows: https://registry-win-tp3.docker.io/v1/
  • Unix: https://index.docker.io/v1/

The Windows url comes from a recent PR 15417 with the comment:

// Currently it is a TEMPORARY link that allows Microsoft to continue
// development of Docker Engine for Windows.

So it is possible this url won't work (unless you are on a very recent Windows Server 2016)


There seems to be a workaround in docker/hub-feedback issues 473, which involves:

  • specifying the default index registry of docker io,

    docker login --username=myuser --password=mypassword --email=myemail https://index.docker.io/v1/
    WARNING: login credentials saved in C:\Users\myuser\.docker\config.json
    Login Succeeded
    
  • modifying the config.json file created by the previous step, in order to add the same credentials for index.docker.io for the registry-win:

config.json:

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

After that, a docker push index.docker.io/myuser/myrepo:latest does work.

like image 57
VonC Avatar answered Oct 15 '22 14:10

VonC