Docker registry with htpasswd not working

Hi guys

I have been trying to get docker registry with authentication working without success.

I generated a password file with:

htpasswd -c htpasswd gary

Generated cert and key:

openssl req
-newkey rsa:4096 -nodes -sha256 -keyout domain.key
-x509 -days 365 -out domain.crt

Created my docker compose file:

registry:
restart: always
image: registry:2
ports:
- 5000:5000
environment:
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
REGISTRY_HTTP_TLS_KEY: /certs/domain.key
volumes:
- data:/var/lib/registry
- certs:/certs
- auth:/auth

Started up my registry

docker-compose up

When I try and login

docker login localhost:5000

I get the following error:

Error response from daemon: no successful auth challenge for https://localhost:5000/v2/ - errors: [basic auth attempt to https://localhost:5000/v2/ realm “Registry Realm” failed with status: 401 Unauthorized]

When I attached to the container and validate the password file

htpasswd -v htpasswd gary

It all works fine.

Any ideas