twuni/docker-registry.helm

htpasswd generation example does not work

akantak opened this issue · 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

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

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

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

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)

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 How would this work for helm and kubernetes?

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.

PR implementing the httpd option is here: #130