Using my own container registry

This will be a short update - just to be consistent about where I describe my configuration gimmicks if I ever need to look things up in the future :-) The problem that is solved in this article is the fact that the Docker Hub free tier only allows hosting of one container image. As I’m already using this freebie for my Airprint Relay image, the recently built nextcloud-backup image requires a different solution.

All has been prepared

If you don’t want to pay for a service, you host your own - which is what I set up many months ago when I came across Docker Hub’s own registry container image. This is the docker-compose file I use:

version: '3'
services:
  registry:
    container_name: registry
    image: registry:2
    ports:
    - "5000:5000"
    restart: unless-stopped
    volumes:
      - registry-data:/var/lib/registry
    networks:
      - registry-ui-net
    healthcheck:
      test: wget -q --spider http://localhost:5000 &>/dev/null || exit 1
      interval: 0m43s
      timeout: 10s
      retries: 3

  ui:
    container_name: registry_ui
    image: joxit/docker-registry-ui:latest
    ports:
      - 5080:80
    environment:
      - SINGLE_REGISTRY=true
      - REGISTRY_TITLE=Homecentral Docker Registry
      - NGINX_PROXY_PASS_URL=http://registry:5000
    depends_on:
      - registry
    restart: unless-stopped
    depends_on:
      - registry
    networks:
      - registry-ui-net

networks:
  registry-ui-net:

volumes:
  registry-data:

Straightforward - I’m just adding a second container to give me a lightweight UI for the registry. Really lightweight, but better than nothing! Note that this is running in my private home network, no links into that from the outside, so I’m not bothering with security, certificates, accounts etc.

Using my own registry

Using a custom container registry is also straightforward - there are two aspects to this: push an image to the registry, and pull from the registry when starting a container. The push part requires the image in question to be tagged with the URL of our custom registry, then that tagged image needs to be pushed. This is for scenarios where e.g. an image was built locally, then we push it to our custom registry to make it available in our network:

docker tag <image_name> <host_url>:<port>/<image_name>
docker push <host_url>:<port>/<image_name>

Once the image is available on the registry (e.g., check via the UI) it can be pulled via docker-compose (or whatever rocks your boat) - I’m providing a sample configuration for the nextcloud-backup container:

version: '3.7'

services:
  nxtcldbackup:
    image: <host_url>:<port>/<image_name>
    container_name: nxtcld-backup
    init: true
    volumes:
      - unison-conf:/root/.unison
      - /mnt/nextcloud:/mnt/source
      - /mnt/raid1/nextcloud:/mnt/backup

volumes:
  unison-conf:

That’s it - this way we push a container image to our custom registry, and docker-compose will pull it from there when running the container.


Waymarks

  • Nothing really. No surprises this week.