Running a Local Docker Registry Proxy Cache

I was talking with a fellow engineer and found out that their team was testing services by having them run locally on the host, not within a vagrant. I thought this was odd and the explanation was it came down to convenance and speed. Bringing up a new vagrant and provisioning it was too slow. I thought about this and wondered how I could potentially help.

My first thought is how can we cache needed items. Vagrant has vagrant-cachier is a plugin that will cache things like apt packages, but we already use that. My second thought was docker images, how could we cache that. Some googling showed trying to use a generic bucket provided by vagrant-cachier wouldn’t work due to how the docker daemon stores images. Some more googling turned up the pull through cache feature of the v2 docker registry.

Using Vagrant and the vagrant docker provisioner, I’ve created a vagrant that runs a local registry proxy cache that can be used by things like docker-machine. You can find it here: https://github.com/davidmnoriega/docker-registry-proxy