I have a docker registry:2 implemented using docker-compose with "htpasswd" authentication. This is working perfectly. I can log in to the registry using "docker login" command by passing the credentials on the terminal. All docker push/pull operations can be performed. However, the curl queries are failing with Authentication Error.
curl -s -H "Content-Type: application/json" -X POST -d '{"username": "regisrty-admin", "password": "Password@123"}' https://my-registry.com:5000/v2/_catalog
ERROR: {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"registry","Class":"","Name":"catalog","Action":"*"}]}]}
Docker-Compose.yml
version: '3.7'
services:
my-registry:
container_name: my-registry
restart: always
image: registry:2
ports:
- "5000:5000"
environment:
REGISTRY_HTTP_ADDR: 0.0.0.0:5000
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
REGISTRY_HTTP_TLS_KEY: /certs/domain.key
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
volumes:
- type: bind
source: /opt/docker/registry/certs/
target: /certs
- type: volume
source: registry_data
target: /data
- type: bind
source: /opt/docker/registry/auth/
target: /auth
volumes:
registry_data:
What is the correct way to use "htpasswd" credentials with CURL command for operations like listing registry images?