Add support for Docker v2 registries
I'm here via Saltstack, and troubleshooting a issue with connectivity while doing a pull. The problem is that the library is hardcoded to reference the v1 API to verify SSL connectivity to a local registry, which does not work with v2 registry.
The request should be changed to also try and ping https:// + hostname + "/v2/" in addition to 'https://' + hostname + '/v1/_ping'
The rest of the pull stream works OK, since it is connecting to Docker, not the repo directly otherwise.
See: https://github.com/docker/docker-py/blob/master/docker/auth/auth.py#L32
This does not appear to have been fixed, as the new ping_registry function is still tryign to hit a _ping endpoint which does not exist in v2.
vagrant@registry-vagrant:~$ curl -v http://localhost/v2/_ping
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /v2/_ping HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=utf-8
< Docker-Distribution-Api-Version: registry/2.0
< Date: Thu, 23 Apr 2015 13:34:46 GMT
< Content-Length: 19
<
404 page not found
* Connection #0 to host localhost left intact
vagrant@registry-vagrant:~$ curl -v http://localhost/v2/
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /v2/ HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Length: 2
< Content-Type: application/json; charset=utf-8
< Docker-Distribution-Api-Version: registry/2.0
< Date: Thu, 23 Apr 2015 13:34:52 GMT
<
* Connection #0 to host localhost left intact
{}
This patch will not work if you have auth enabled registry 2.0. More info
https://github.com/docker/docker/blob/v1.6.0/registry/auth.go#L342