I am adding authentication to my docker private registry in windows 10. I have initially not implemented basic authentication but later, I implemented it using a htpasswd file which is in my auth folder. I have been following up on the instructions given in this tutorial: https://www.codeproject.com/Articles/1263831/How-to-secure-your-private-Docker-Registry . But because windows was having issues with the htpasswd file hence, I had to create a htpasswd file using HtPasswd generator and copied it to my auth folder.
Later, I ran this command to build a container and binding volume, port and htpasswd file from host to my container:
docker run -d -p 5000:5000 --name hub.local -v C:\localHub\registry:/var/lib/registry -v C:\localHub\auth:/auth -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/.htpasswd -e REGISTRY_HTTP_ADDR=0.0.0.0:5000 registry:2
It works fine, and I can see the container is up and running on port 5000:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
41499c3f07e6 registry:2 "/entrypoint.sh /etc…" 17 minutes ago Up 17 minutes 0.0.0.0:5000->5000/tcp hub.local
but when I try to login into my container using docker login 172.16.13.38:5000
it asks me for username and password but shows the same error.
docker login 172.16.13.38:5000
Username: muskan
Password:
Error response from daemon: login attempt to http://172.16.13.38:5000/v2/ failed with status: 401 Unauthorized
I have double checked that the htpasswd file is there in the container's auth folder and my registry is up at http://172.16.13.38:5000/v2/_catalog
Kindly help me with this. I am not able to figure it out and have been trying since last two days.
htpasswd file has this content:
muskan:$apr1$k9......$4fyyuas7/VfnuBnPRbFI//
docker run --entrypoint htpasswd httpd:2 -Bbn USERNAM_HERE PASSWORD_HERE > PATH_TOVOLUME/htpasswd
After you have the htpasswd file, you point to its location
Example here is use docker-compose
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
REGISTRY_STORAGE_DELETE_ENABLED: 'true