Docker registry V2

(λx.x)eranga
Effectz.AI
Published in
4 min readDec 3, 2015

About docker registry

You can build your own images(with multiple containers) by using docker.To build your images you use various apps, libraries etc. Then two problems comes.

  1. Where does the apps and libraries comes from
  2. How/Where we store these images

To solve this problem docker introduces docker-registry. Docker registry allows you to upload, download and share your own images. If simply says, the Docker registry is Docker’s in-build way to share images

You can take/pull libraries, apps from registry to build your images. After building images you can upload/push your images to the registre. These pushed images can be downloaded in another environment.

Docker provide a official, public docker registry call docker hub. You can put your images on it. But if you want to put your private, company specific images you can build your own docker registry and host it in a public/private domain.

Docker registry V2

Latest version of the docker registry is V2(Previous one is V1). V2 registry works with docker version 1.6+. In older versions of docker you have to use registry V1. V2 registry API provide various new functionalities than V1.

  1. Faster push and pull
  2. New, more efficient implementation
  3. Simplified deployment
  4. Pluggable storage backend
  5. Webhook notification
  6. etc..

Setup V2 registry

Docker registry V2 comes as a docker image. You can simply pull it and run it. In this scenario registry runs on port 5000 in your machine.

docker run -d -p 5000:5000 --restart=always --name registry registry:2
docker ps

This will start to run new docker registry on your host. You can pass various options with this docker run command. Most important one is where to store the images. You can map a volume for it.

docker run -d -p 5000:5000 — restart=always — name registry \ -v `pwd`/data:/var/lib/registry \ registry:2

In this scenario all your images will be stored in ./data folder (inside current directory). Now you can simply tag your images and publish to this registry.

tag the image

Note that my registry is running on local ip(10.2.4.110). You can point it to your host ip.

publish images

If you want to work with this registry with out using any public key certificate you have to mark it as a insecure registry (in your docker daemon). To make it you have to add an entry to your docker config file. Docker config file locates

  1. /etc/default/docker in Linux
  2. /var/lib/boo2docker/profile in OSX (inside boot2docker VM)

Add following entry to the config file.

DOCKER_OPTS=” — insecure-registry <registry host>:5000"
docker opts

Set up docker registry UI

If you want to browse, search, update the images in you private registry you can run a web UI for your registry. There are various open source projects available to build your own web UI. I’m using following project a projecton github docker-registry-frontend (it supports for docker registry V2).

To run the registry UI issue following command

docker run \
-d \
-e ENV_DOCKER_REGISTRY_HOST=ENTER-YOUR-REGISTRY-HOST \
-e ENV_DOCKER_REGISTRY_PORT=ENTER-PORT-TO-YOUR-REGISTRY-HOST \
-p 8080:80 \
konradkleine/docker-registry-frontend:v2
Registry UI

If you browse <your host>:8080 following would be your registry UI

Registry UI

Following are the exiting images of my registry

Registry UI images

Reference

  1. https://github.com/kwk/docker-registry-frontend/wiki/Features
  2. https://github.com/docker/distribution/releases
  3. https://coderwall.com/p/zafv9g/use-private-docker-registry-in-os-x

--

--