About Archives
 

Docker Registry using Digital Ocean's EBS

 

Imagine running your own Docker Private Registry in a Digital Ocean droplet
using an Elastic Block Storage volume to store your Docker images,
while also using a Web UI similar to the one in Docker Hub to browse it.

Interested? Keep reading.

TL;DR

Use the instructions below to test it.

Requirements

  • Docker Machine
  • Docker Engine (installed locally)
  • DigitalOcean API Keys
  • git

Instructions

Clone francolaiuppa/docker-registry-elastic-storage, edit default.env and run ./setup.sh.

The DIY way

Requirements

  • DigitalOcean account

Instructions



Ensure df -h output looks like this

1
2
3
4
5
6
7
8
9
[root@docker-private-registry ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 1.2G 37G 4% /
devtmpfs 912M 0 912M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 17M 904M 2% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
tmpfs 184M 0 184M 0% /run/user/0
/dev/sda 30G 45M 28G 1% /mnt/volume-nyc1-01

Install latest Docker

1
yum update && curl -fsSL https://get.docker.com/ | sh

Make Docker run on startup

1
chkconfig docker on

Install lvm

1
yum install -y lvm2*

Create LVM group and setup Docker to use it

1
2
3
4
5
6
7
8
9
10
11
12
pvcreate -f /dev/sda
vgcreate docker /dev/sda
lvcreate --wipesignatures y -n thinpool docker -l 95%VG
lvcreate --wipesignatures y -n thinpoolmeta docker -l 1%VG
lvconvert -y --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta
curl -o /etc/lvm/profile/docker-thinpool.profile \
https://raw.githubusercontent.com/francolaiuppa/docker-registry-elastic-storage/master/docker-thinpool.profile
lvchange --metadataprofile docker-thinpool docker/thinpool
curl -o /etc/docker/daemon.json \
https://raw.githubusercontent.com/francolaiuppa/docker-registry-elastic-storage/master/daemon.json
rm -rf /var/lib/docker
systemctl daemon-reload

Start Docker

1
systemctl docker start

Create data folders

1
2
mkdir -p /var/www/registry/data
chmod 777 /var/www/registry/data

Run Docker Registry

1
docker run -d --name registry -p 5000:5000 -v $(pwd)/data:/tmp/registry-dev registry:2.5.0

Run Registry Frontend (Remember to replace DROPLET_IP_GOES_HERE with your Droplet IP Address!

1
2
3
docker run -d -e ENV_DOCKER_REGISTRY_HOST=DROPLET_IP_GOES_HERE \
-e ENV_DOCKER_REGISTRY_PORT=5000 \
-p 8080:80 konradkleine/docker-registry-frontend:v2

Visit http://DROPLET_IP_GOES_HERE:8080 and enjoy

Final notes

This example is far from being done and it could be further improved by adding SSL, Authentication for both Registry and Frontend, but that’s a talk for another post.