Sometimes you need to store your docker images in a private environment instead of using a hosted one (e.g. Azure Container Registry). So you have to deploy your own registry to your own hosting environment. Below is step by step the procedure I have followed

Step 1 – Docker Compose File

Create a docker-compose file like this:

version: '3'

services:
  docker-registry:
    image: registry:2
    ports:
      - 443:5000
    volumes:
      - ./auth:/auth
      - ./certs:/certs
    environment:
      - REGISTRY_AUTH=htpasswd
      - REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm
      - REGISTRY_AUTH_HTPASSWD_PATH=/auth/registry.password
      - REGISTRY_HTTP_TLS_CERTIFICATE=/certs/yourcert.crt
      - REGISTRY_HTTP_TLS_KEY=/certs/yourcert.key

As you can see there are two volumes: auth and certs which have to exist in the same level with docker-compose.yml

Step 2 – Adding SSL certificates

In the certs folder you have to put your ssl certificates (if you want to secure your registry). The needed files are the certificate and the private key file

Step 3 – Adding authentication

In the auth folder you have to keep your password for your own registry. To achieve this you have to

  • sudo apt install apache2-utils
  • htpasswd -Bc registry.password someuser (you will be prompt to give the password)

Then in order to use this registry you will have to run the login command

docker login localhost

Step 4 – Adding a UI

I selected the UI from this page https://github.com/Quiq/docker-registry-ui which is very easy to make it work. You just clone the repository and change the config.yml inside the directory. The three required fields to change are the following

registry_url: <Your registry URL IP/Domain>
registry_username: <username>
registry_password: <password>

By admin