Install private docker registry
1 min read

Install private docker registry

Install private docker registry

Following the previous post, I have now everything ready to install my own registry.

NAS storage

I've created a new place (dataset) on my NAS server to store the registry's images and shared it via NFS. I've mounted it on my destination machine:

- name: Create docker registry directory
  file:
    path: /mnt/docker-registry
    state: directory

- name: Mount docker registry folder (NFS)
  mount:
    src: '(NAS IP):/mnt/Main/data/docker-registry'
    name: /mnt/docker-registry/
    state: mounted
    opts: 'tcp,acl'
    fstype: nfs
  become: yes

Ansible configuration

- name: Install private docker registry
  docker_container:
    name: docker_registry
    hostname: 'docker.{{ domain_suffix }}'
    image: 'registry:2'
    restart_policy: 'always'
    recreate: yes
    ports:
      - '15000:5000'
      - '15443:443'
    volumes:
      - '/mnt/docker-registry:/var/lib/registry'
      - '/etc/certificates:/certs'
    env:
      REGISTRY_HTTP_TLS_CERTIFICATE: '/certs/my.crt'
      REGISTRY_HTTP_TLS_KEY: '/certs/my.key'
      REGISTRY_HTTP_SECRET: '{{ docker_registry_secret }}' # stored in an encrypted *secrets* file
      REGISTRY_HTTP_ADDR: '0.0.0.0:443'

Now, the registry is up and running. If you think there's something missing and the registry doesn't seem to be up, go check the logs. They're quite explanatory.

HTH,