Introduction
This document will describe the process to setup / run an private docker registry v2. This come handy when you need to have a private image repository. Why you might need this ? Imagine that you need a fast local registry or if you feel uncomfortable pushing you private work to docker hub.
If you search the docker documentation they recommend to use it as a container. That will work in most of the cases. In our case we wanted to have it running on a standalone server, to store the data on a shared storage and several other reasons (speed is one of the reasons).
Installation
What we need is epel repo installed and we need to install docker-distribution
| root@tfm-swrm01: yum search docker-distributionLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * epel: epel.check-update.co.uk======================= N/S matched: docker-distribution =======================docker-distribution.x86_64 : Docker toolset to pack, ship, store, anddeliver                           : content  Name andsummary matches only, use"search all"foreverything. | 
at the time of writing this article the version available is 2.4.1:
| [root@tfm-swrm01 registry]# yum info docker-distributionLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * epel: epel.check-update.co.ukInstalled PackagesName        : docker-distributionArch        : x86_64Version     : 2.4.1Release     : 2.el7Size        : 15 MRepo        : installedFrom repo   : extrasSummary     : Docker toolset to pack, ship, store, anddeliver contentURL         : https://github.com/docker/distributionLicense     : ASL 2.0Description : Docker toolset to pack, ship, store, anddeliver content | 
Installing it is pretty forward:
| yum install -y docker-distribution | 
To enable docker registry to run at boot
systemctl enable docker-distribution.service
and to start it:
systemctl start docker-distribution.service
Configuration
Configuration is done via /etc/docker-distribution/registry/config.yml . We decided to start with a minimal configuration file and add additional setting later. Below is a configuration file that works :
| version: 0.1log:  fields:    service: registrystorage:    cache:        layerinfo: inmemory    filesystem:        rootdirectory: /data/docker-registryhttp:    addr: :5000 | 
Our shared storage is mounted in /data so keeping images in /data/docker-registry makes sense.
Remember that docker registry supports a lot of storage backend drivers (Local file system,Microsoft’s Azure Blob Storage,Google Cloud Storage, Amazon’s Simple Storage Service (S3) , Openstack Swift object storage, Aliyun OSS for object storage) but we will use local filesystem for now.
Docker has comprehensive documentation regarding parameters supported in config.yml, you can find it at Registry Configuration Reference and we recommend to check it in order to understand what are all the options you can configure.
Using it
1) Build a container and tag it to use the custom repository
docker build /tmp/grafana -t 192.168.1.1:5000/custom_grafana
2) Push the image to repository:
docker push 192.168.1.1:5000/custom_grafana
Thanks a lot!