docker login registry.gitlab.com/v2 does not work with Docker version 17.06.2-ce
Summary
Docker login with Docker version 17.06.2-ce does not work in the default version of the v2 api at registry.gitlab.com
Steps to reproduce
I am not running proxies at all and the setup has not changed on one of our server running 17.06.2-ce.
But if i force the login on the v1 api of the registry it works. I
Current behaviour on Docker version 17.06.2-ce
On the server i see
docker -v
Docker version 17.06.2-ce, build cec0b72
docker login https://registry.gitlab.com
Username: USER
Password:
Error response from daemon: Get https://registry.gitlab.com/v2/: error parsing HTTP 403 response body: unexpected end of JSON input: ""
correct behavior
It works correctly on my PC where i run a new version of docker 19.03.12
$ docker -v
Docker version 19.03.12, build 48a66213fe
docker login registry.gitlab.com
Authenticating with existing credentials...
Login did not succeed, error: Error response from daemon: Get https://registry.gitlab.com/v2/: unauthorized: HTTP Basic: Access denied
Username (USER): USER
Password:
WARNING! Your password will be stored unencrypted in /home/USER/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
Forcing the use of v1 api works but this might not be obvious and is unexpected
docker login https://registry.gitlab.com/v1/
Username: USER
Password:
Login Succeeded
Possible fixes
Maybe you can detect the docker version used by clients and redirect them to the internal v1 API so it does not break on v2.