dotcloud/docker-registry — pull request #489 by bacongobbler (2014-07-23 15:37:07+00:00)
Title: feat(tags): add registry-to-registry transfers

This new endpoint takes a source registry to pull from and imports the specified
repository to the current registry. This follows the same syntax as how the docker client
pulls repositories.

In PaaSLand (both public and private), users want to run their images which are stored
from their own registries or from DockerHub. Specifically for [Deis](http://deis.io), we
need a way to be able to pull images from their registry (or DockerHub) over to our
in-house registry. We make the assumption that every user has access to their own
registry, so we can't tie down to mirroring from a single remote. The only way we see
that we can in the current implementation is to:

1. run a docker client
2. pull the image from the client's registry
3. push the image to the PaaS' in-house registry (after doing some last-mile layer
configuration)
4. pull it down from the host that will be running the application.

This is too slow for our needs and is very inefficient (pull, push, then pull again).
We'd like to have some way that we can import an image directly from a remote registry.
This would reduce the processing time significantly. Mirroring works for mirroring against one specific index, which is not suitable for our needs.

This commit introduces a new endpoint for the in-house registry:

POST /v1/repositories//tags 'src=example.com:5000/busybox'

This endpoint will pull the repository and all corresponding tags that come with it from
the remote registry and store it locally. If the repository already exists, then it will
pull any layers missing from the remote and update the tag metadata to point to the new
image IDs. This behavior is equivalent to how `docker pull` works.

Admittedly, this PR has a huge amount of spaghetti code and could definitely use improvement, but I wanted to propose this PR to see if there are better ways to accomplish what we are trying to do.