I'm working on a simple REST client for Docker Registry. For private registries, name resolution is pretty simple; if the image name is myregistry.io/myimage:latest
, I look for https://myregistry.io/v2
and query the API there.
However, I notice that for docker hub, it doesn't quite work that way. If I'm looking for ubuntu
, I can expand that to docker.io/ubuntu:latest
, but https://docker.io/v2
returns a 307 redirect to https://www.docker.com/v2
, which just returns HTML. The actual registry endpoint is at https://registry-1.docker.io/v2
.
Is this just a hardcoded special case in the docker client, or is there some extra logic to looking up registry endpoints that I'm unaware of? If it is just a special case, is there more to it than always going to registry-1.docker.io
instead of docker.io
?
The central Docker registry is a well-known special case, similar to Maven central. You can see the defaults e.g. at https://github.com/docker/docker-ce/blob/ea449e9b10cebb259e1a43325587cd9a0e98d0ff/components/engine/registry/config.go#L42: