This post describes how to configure the registry by injecting the config file into the container at build time. The official documentation describes how to overwrite variables one by one using environment variables, however I prefer injecting the config entirely, it’s more obvious.

Version 2 of the docker registry was released on April 16th, 2015. The official documentation describes reasonably well how to start the container but it falls very short when it comes to describing how to configure it. My goal was to create my own registry image with my own Dockerfile, based on the official registry:2.0 image. I wanted to be able to “copy in” my own config file for the registry, which would replace the default config file. As I mentioned I much prefer this approach to setting environmental variables because it is much clearer to me how my registry is set up. This way I know that my config file is the one and only config file which will be used, reducing headaches and WTF moments.

However, there’s not a lot of info about how to do this (at least not at the time of writing). In particular the bit that puzzled me was “where is the config file inside the container?”. I needed this so that I could replace it with my own customized config file.

Here’s the Dockerfile that will do it:

FROM registry:2.0

MAINTAINER Emmet O'Grady <e...@gmail.com>

COPY config/registry-config.yml cmd/registry/config.yml

That’s all there is to it. Just base your config/registry-config.yml on the default one from the official repo and customize whatever you want to.