Docker login (400 error)

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 Like

The password file path is wrong.
In your first cmd ,the path is /auth/htpasswd, but in your second cmd, the path is /root/auth/htpasswd,
they are not the same one, so the registry can not find right password file.