Prerequisites

  • Local network
  • A machine that can run docker and docker-compose

In this guide i will be using a ubuntu 18.04 virtual machine on Virtualbox connected to the local network via bridged adapter.

Preperation

Server installation

  • Retrieve ubuntu server 18.04 image from here.
  • Create a new virtual machine in Virtualbox, set network adapter attached to bridged adapter.
  • Install ubuntu server on this virtual machine.

Networking

Install avahi-daemon via apt, this ensures that your virtual machine will show up under the name of hostname.local, for this machine, i set the hostname to ubuntu. Any instructions below will use this hostname.

Docker

Follow the official instructions to install docker on the server.

Optional: Add user to docker group to use docker without root

sudo usermod -aG docker your-user

Miscellaneous Dependencies

Install docker-compose and git if not installed.

sudo apt install docker-compose git

Deploying Docker Registry

  • Clone this repository from GitHub which includes the required configuration files.

    git clone https://github.com/glacion/lan-docker-registry
    
  • Go to the fetched directory

    cd lan-docker-registry
    
  • Run the server

    docker-compose up -d
    

Testing The Deployment

  • Pull the busybox image from the local registry, this will trigger the registry to cache the busybox image.

    docker pull localhost/library/busybox
    
  • Acquire the container id of the registry.

    $ docker ps --format "{{ .ID }} {{ .Image }}"
    9e898cde9182 registry:2
    804903ce9f7e redis:alpine
    

    This shows that 9e898cde9182 is the container id of my registry container.

  • Check for errors and warnings of the registry.

    docker logs 9e898cde9182 2>&1 | grep -E "level=(warning|error)"
    

    Currently, the only output to this should be a warning level log with message

    Registry does not implement RempositoryRemover. Will not be able to delete repos and tags
    
  • Remove the busybox image

    docker image rm localhost/library/busybox
    
  • Re-pull the busybox image

    docker pull localhost/library/busybox
    
  • Recheck the logs, if there are no new entries, the registry is working correctly.

Client Configuration

Clients to this registry must be configured to use the newly created server as proxy.

  • In a client machine, edit docker daemon settings.
    For a linux client, edit /etc/docker/daemon.json,
    For a mac client, use Preferences -> Docker Engine

  • The file should look like this:

    {
      "registry-mirrors": [
          "http://ubuntu.local"
      ],
      "insecure-registries": [
          "ubuntu.local"
      ]
    }
    

Keep any other items as-is.