Docker: Create your own private Docker registry

By | October 24, 2016

Docker is a nice low-cost virtualization solution that is more and more popular.
A very nice use case is to use it to create images of enterprise systems, images that can be used for testing without having to bother to delete databases and reinitialize testing environment. You just simply have to fire up another set of containers and your test environment starts again in a predefined set.

The problem in using the default infrastructure is due to security concerns. I do not want to upload company sensitive data to the public docker.io repository.
In the next steps I am going to show how to install and use a simple local docker register.

Step 1: Get the registry docker image

Docker registry can be very easy deployed from a ready available docker image itself. Search the docker.io global repository for the image “registry:2”
Fetch the image on the local system.

STEP 2: Add a new local private registry

Start a new docker registry container. This will start a simple registry with no security enabled.

STEP 3: Allow the local docker daemon to access insecure registries

Edit on client the docker config file. On Fedora/RedHat/CentOS edit /etc/sysconfig/docker and add at the end of the file:

In new versions of docker > 1.12, Create or modify /etc/docker/daemon.json

where 10.0.0.245 is my local IP under which the custom registry will be accessible.

Restart docker daemon to activate the above configuration change.

STEP 4: Tag and push local images to the new registry

List the existing images:

Tag local images to the new registry. Note the name used must correspond to the fully qualified name of the registry resources.

List the existing images after tagging. Note that now the tagged images have two aliases,

Push the docker images to the new registry.

To connect to the new registry just login from any local client, no user/password required, just enter some info.

Advertisements

6 thoughts on “Docker: Create your own private Docker registry

  1. George Voina

    I will give it a try. I use the described registry only for a small test setup. I plan to have a server deploy soon using some proper “enterprise” repository setup. Thank you for the suggestion.

  2. Derek E. Weeks

    Another option you might consider is using an open source application like Nexus Repository. Nexus is purpose built to manage artifacts required for builds and deployments, and can also act as a proxy to Docker Hub and other private warehouses. In addition to serving as a private Docker registry, you can use it to store other artifacts needed by Dev and Ops teams. You can read more about this at http://www.sonatype.com/docker