1

I setup an insecure private registry using:

[root@docker-regi ~]#docker run --entrypoint htpasswd registry:2 -Bbn myuser mypassword > /auth/htpasswd

[root@docker-regi ~]#docker run -d -p 5000:5000 --restart=always --name registry_auth  -v `pwd`/auth:/auth  -e "REGISTRY_AUTH=htpasswd"  -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm"  -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd"  registry:2

But when trying to login:

[root@docker-remote ~]# !748
docker login -u myuser -p mypassword 192.168.122.190:5000
Error response from daemon: login attempt to http://192.168.122.190:5000/v2/ failed with status: 400 Bad Request
[root@docker-remote ~]# 

Referred to https://docs.docker.com/registry/deploying/#native-basic-auth && https://github.com/docker/distribution/issues/842

1

In the first command you wrote out the htpasswd to:

/auth/

then you mounted:

`pwd`/auth

So those directories don't match, you never actually mounted the htpassswd file

If you write out to auth/htpasswd it will work since it's writing to your current directory, not to /

The following worked perfectly for me:

mkdir auth

docker run --entrypoint htpasswd registry:2 -Bbn myuser mypassword > auth/htpasswd

docker run -d -p 5000:5000 --restart=always --name registry_auth  -v `pwd`/auth:/auth  -e "REGISTRY_AUTH=htpasswd"  -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm"  -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd"  registry:2

docker login -u myuser -p mypassword localhost:5000

Returns:

Login Succeeded

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy