Setting Up A Local Docker Registry

#docker #sysadmin

The goal of this is to have a docker registry setup on my local network.

I used the Testing an insecure registry for instructions on how to set it up.

$ mkdir -p certs && openssl req \
    -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key \
    -x509 -days 365 -out certs/domain.crt

After that, I copeied the domain.crt file to the /usr/local/share/ca-certificates directory as hostname.crt, then ran update-ca-certificates to make it trusted by Ubuntu.

Below is a docker-compose entry for the host:

registry:
    environment:
      REGISTRY_HTTP_TLS_CERTIFICATE: '/certs/domain.crt'
      REGISTRY_HTTP_TLS_KEY: '/certs/domain.key'
    hostname: registry
    image: registry:2
    ports:
      - '5000:5000'
    restart: unless-stopped
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - /config/registry:/certs:ro
      - /data/registry:/var/lib/registry

Now I can docker build -t hostname:5000/image . and then docker push hostname:5000/image to push the image to the remote registry.