Setup and run a standalone private docker registry v2

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-distribution
Loaded plugins: fastestmirror, langpacks
Loading 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, and deliver
                           : content
  Name and summary matches only, use "search all" for everything.

at the time of writing this article the version available is 2.4.1:

[root@tfm-swrm01 registry]# yum info docker-distribution
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * epel: epel.check-update.co.uk
Installed Packages
Name        : docker-distribution
Arch        : x86_64
Version     : 2.4.1
Release     : 2.el7
Size        : 15 M
Repo        : installed
From repo   : extras
Summary     : Docker toolset to pack, ship, store, and deliver content
URL         : https://github.com/docker/distribution
License     : ASL 2.0
Description : Docker toolset to pack, ship, store, and deliver 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.1
log:
  fields:
    service: registry
storage:
    cache:
        layerinfo: inmemory
    filesystem:
        rootdirectory: /data/docker-registry
http:
    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

 

Creating a TFM Vagrant Box from Scratch

tfm logoCreating a Vagrant box from a TFM/GNU Linux image tutorial. It’s an easy 10 step tutorial that will alow you to have a development box based on TFM/GNU Linux

1) Create a new Virtual Machine in VirtualBox

Type: Linux
Version: Linux (64-bit)
Memory Size: 2048MB
New Virtual Disk:
Type: VMDK (Dynamically allocated)
Max Size: 40GB

2) Modify Virtual Machine settings:

* Disable audio
* Disable USB
* Ensure Network Adapter 1 is set to NAT
* Mount the TFM Linux ISO

3) Add the vagrant group and user and set password to vagrant

groupadd vagrant
useradd -m -g vagrant
passwd vagrant

4) Modify /etc/sudoers

Defaults:vagrant !requiretty
#Defaults !visiblepw
Defaults env_keep = “SSH_AUTH_SOCK”
vagrant ALL=NOPASSWD: ALL

5) Add vagrant ssh key to allow logins

mkdir -p /home/vagrant/.ssh
chmod 0700 /home/vagrant/.ssh
wget –no-check-certificate \
https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub \
-O /home/vagrant/.ssh/authorized_keys
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant /home/vagrant/.ssh

6) modify /etc/ssd/sshd_config

Port 22
PubKeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PermitEmptyPasswords no
PasswordAuthentication no

7) Install the Guest Tools for our VM package.
* From Virtualbox Install Guest Additions…
* from linux prompt:

mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
/mnt/cdrom/VBoxLinuxAdditions.run
umount /mnt/cdrom

8) Adjust the base settings of the configuration

echo “dhclient eth0” > /etc/init.d/local
echo “nameserver 8.8.8.8” >/etc/resolv.conf
ln -s /etc/init.d/local /etc/rc.d/rc3.d/S99local
ln -s /etc/init.d/vboxadd /etc/rc.d/rc3.d/S25vboxadd

9) Shutdown the TFM guest OS .

shutdown -h now

10) Pack and distribute the image

vagrant package –base vagrant-tfm

vagrant box add dev-new http://hq.tfm.ro/vagrant/vagrant-tfm.box
vagrant init dev-new
vagrant up

So … Happy developing .

Some thoughts ( depending on what you want that machine for ):
– You will probably want to mount a local directory into VM
– You probably want to start nginx / mysql / php-fpm
– Maybe the you want to add the logs on the local machine …

New CMS needed for tfm.ro

tfm.ro needs a new face. in the beginning we started with an inhouse mini CMS. Then we switched to mediawiki and focused on end user documentation and howto. At this point we use wordpress with Structure theme .

What is not ok:

  • Community options are limited
  • User generated content is limited to comments
  • Integration with the development site is done only via an RSS feed
  • Looks old and dusty
  • We focus on development and by doing this the site is most of informations are old and sometime obsolete

So ,  i’m begining to search for an alternative that will have to provide:

  • community options ( registration , posibility to upload pictures , patches , docs etc )
  • bug tracker integrated with the main site
  • online manuals creation / gathering
  • forums

Do you know what options are out there ?