docker-registry.helm icon indicating copy to clipboard operation
docker-registry.helm copied to clipboard

htpasswd generation example does not work

Open akantak opened this issue 4 years ago • 8 comments

The example of htpasswd file generation does not work:

$ sudo docker run --entrypoint htpasswd registry:2 -Bbn user password > ./htpasswd
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "htpasswd": executable file not found in $PATH: unknown.
ERRO[0000] error waiting for container: context canceled

I tested that with recent image:

REPOSITORY                                         TAG                            IMAGE ID       CREATED         SIZE
registry                                           2                              1fd8e1b0bb7e   5 months ago    26.2MB

akantak avatar Sep 30 '21 12:09 akantak

There appears to be something broken in the latest pull. I believe there is a pull request pending to fix the documentation. For anyone reading this though...

Try this instead: docker run --entrypoint htpasswd registry:2.7.0 -Bbn user password > ./htpasswd or docker run --rm -ti xmartlabs/htpasswd username password >> ./htpasswd

Mytholody avatar Nov 23 '21 18:11 Mytholody

How can a password file be generated on aks where there is no docker access? I've tried generating the file manually but get permission denied

ross-worth avatar Dec 08 '21 13:12 ross-worth

I'm not familiar with Azure-based setups, but it shouldn't be a problem. You can run it on your local machine and take the key.

Run this with your username and password replaced (and just input the string that is output for your secrets.htpasswd parameter and you should be good to go): docker run --entrypoint htpasswd registry:2.7.0 -Bbn user password

Mytholody avatar Dec 08 '21 23:12 Mytholody

I'm not familiar with Azure-based setups, but it shouldn't be a problem. You can run it on your local machine and take the key.

Run this with your username and password replaced (and just input the string that is output for your secrets.htpasswd parameter and you should be good to go): docker run --entrypoint htpasswd registry:2.7.0 -Bbn user password

Thanks Mytholody, that was exactly what I was looking for (which parameter to store the data in)

ross-worth avatar Dec 09 '21 08:12 ross-worth

See: https://stackoverflow.com/questions/62531462/docker-local-registry-exec-htpasswd-executable-file-not-found-in-path/71658782#71658782

htpasswd was removed from the latest docker registry images. You can use httpd instead:

 mkdir auth
 docker run \
  --entrypoint htpasswd \
  httpd:2 -Bbn testuser testpassword > auth/htpasswd

pieveee avatar Mar 29 '22 09:03 pieveee

@pieveee How would this work for helm and kubernetes?

wethinkagile avatar Jan 29 '23 01:01 wethinkagile

Just setup a basic auth within the ingress-resource of the chart using annotations and you can now have basic auth. Keep in mind creating the secret in the htpasswd format.

fguevara-attackiq avatar Jun 15 '23 12:06 fguevara-attackiq

PR implementing the httpd option is here: https://github.com/twuni/docker-registry.helm/pull/130

wkbrd avatar May 14 '24 15:05 wkbrd