Running a private Docker registry server

This quick and dirty short guide will cover setting up your own private Docker image registry server with the default configuration. Image and repository storage is via a local filesystem which is mounted as a volume.

More advanced setup information is available if this guide is insufficient.

Get the registry server

The Docker registry server has an official image in the Docker hub:

$ docker pull registry:latest

If you want all previous versions then you can run:

$ docker pull registry

Running the registry server

We will start the server using the default configuration file, but will mount the image and repository storage path as a volume.

The storage path the server uses can be configured by setting the environment variable STORAGE_PATH.

$ mkdir /path/to/docker-registry
$ docker run -d --name docker-registry -p 5000:5000 -v /path/to/docker-registery:/registry -e STORAGE_PATH=/registry registry:latest

If you want to use a different configuration file then you can specify its location with the DOCKER_REGISTRY_CONFIG environment variable or you can configure a different settings profile by setting SETTINGS_FLAVOR.

Testing the registry server is running

Run the following:

$ curl localhost:5000

And you will receive back the current version of the server and which setting profile it is using.

Pushing images to your registry server

Images need to be tagged in the form of server-address:port/image-name before they can be sent to the server. Using a local copy of the Docker client, we will retag the official Ubuntu image and then push it to the server.

$ docker pull ubuntu:14.04
$ docker tag ubuntu:14.04 localhost:5000/ubuntu
$ docker push localhost:5000/ubuntu

The image now exists on your private server and you can test this by pulling it. But first we’ll remove it from the local Docker server.

$ docker rmi localhost:5000/ubuntu
$ docker images
$ docker pull localhost:5000/ubuntu
$ docker images

And you can now see the image again.

Providing access to your registry server

The recommended way to for providing access to your registry server is via a proxying server (nginx is recommended). Additionally you can also add password protection (such as Basic auth) for controlling access to it and/or configure SSL for encrypted access.

Further details on setting up nginx or Apache can be found here.


Adam Bell-Hanssen

maybe, someday .. just another code and ops guy

Oslo, Norway