docker-py icon indicating copy to clipboard operation
docker-py copied to clipboard

Add support for Docker v2 registries

Open garrickp opened this issue 11 years ago • 2 comments

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

garrickp avatar Apr 21 '15 21:04 garrickp

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
{}

garrickp avatar Apr 23 '15 13:04 garrickp

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

avdhoot avatar May 06 '15 06:05 avdhoot