Docker Registry

Overview

I have a requirement to create a local Docker Registry. I’m doing this because I have four Kubernetes clusters to somewhat mirror the work environment. This lets me test out various new bits I want to apply to the work environment but without using up work resources or involving multiple groups. In addition, we’re on high speed WiFi so we have a pretty small pipe in general. So I’m not constantly using up bandwidth, hosting it locally is the next best thing.

Currently work is using Artifactory. Artifactory has some cool features for Docker in that I can create a Virtual Repository that consists of multiple Remote Repositories. So I can have a group specific Virtual Repository to be used in hosting images and when I try to pull a new image, such as kube-apiserver v1.18.8, Artifactory automatically pulls it into the Virtual Repository. Very nice.

Unfortunately, the Docker management features of Artifactory are a paid for product and in looking at the costs, I can’t justify paying that for my own learning purposes. Hence I’m installing the default Docker Registry.

Installation

It’s actually a pretty simply process overall. I have a CentOS 7 server created, bldr0cuomrepo1.internal.pri, and install the docker-distribution RPM which is part of the extras repository.

Check the configuration file located in /etc/docker-distribution/registry/config.yaml for any changes I might want to make. In my case, the default is fine.

version: 0.1
log:
  fields:
    service: registry
storage:
    cache:
        layerinfo: inmemory
    filesystem:
        rootdirectory: /var/lib/registry
http:
    addr: :5000

And finally enable and start the docker-distribution.

# systemctl enable docker-distribution
# systemctl start docker-distribution

Insecure

Okay, well this is an insecure registry as far as Docker and Kubernetes is concerned. As such, I need to make a change to the /etc/docker/daemon.json file.

{
        "insecure-registries" : ["bldr0cuomrepo1.internal.pri:5000"]
}

And of course, restart docker.

Image Management

Now if you want to host your own images for Kubernetes, you can host it locally and have your deployment point to the local registry. In addition, you can pull commonly used images from the internet and host them locally.

# docker pull nginx:alpine

Then you need to tag the image. This involves changing the location from the various internet sites like docker.io, k8s.gcr.io, and quay.io, to your new local repository.

# docker tag nginx:alpine bldr0cuomrepo1.internal.pri:5000/nginx:alpine

Once pulled, you can run a docker image ls to see the installed images. Then you can push it up to your repository.

[root@bldr0cuomifdock1 ~]# docker push bldr0cuomrepo1.internal.pri:5000/llamas-image:v1
The push refers to repository [bldr0cuomrepo1.internal.pri:5000/llamas-image]
ca01cce58e28: Pushed
a181cbf898a0: Pushed
570fc47f2558: Pushed
5d17421f1571: Pushed
7bb2a9d37337: Pushed
3e207b409db3: Pushed
v1: digest: sha256:4a0a5e1d545b9ac88041e9bb751d2e2f389d313ac5a59f7f4c3ce174cd527110 size: 1568

And now that it’s hosted locally, you can pull it to any server where docker is installed.

[root@bldr0cuomifdock1 data]# docker pull bldr0cuomrepo1.internal.pri:5000/llamas-image:v1
v1: Pulling from llamas-image
cbdbe7a5bc2a: Pull complete
10c113fb0c77: Pull complete
9ba64393807b: Pull complete
262f9908119d: Pull complete
c4a057508f96: Pull complete
e044fc51fea0: Pull complete
Digest: sha256:4a0a5e1d545b9ac88041e9bb751d2e2f389d313ac5a59f7f4c3ce174cd527110
Status: Downloaded newer image for bldr0cuomrepo1.internal.pri:5000/llamas-image:v1
bldr0cuomrepo1.internal.pri:5000/llamas-image:v1
This entry was posted in Computers, Docker. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *