what does "-Bbn" means in Docker?

Viewed 531

I followed this article Docker Registry to set up a restricted access docker registry. I don't understand the following snippet.

$ docker run \
  --entrypoint htpasswd \
  registry:2 -Bbn testuser testpassword > auth/htpasswd

I checked the docker official docker run document, but I didn't find the -Bbn reference.

Question

What does -Bbn means?

Where can I find the document of -Bbn?

2 Answers

-Bbn are the arguments of htpasswd command (https://httpd.apache.org/docs/2.4/programs/htpasswd.html), which is specified in argument

--entrypoint htpasswd

The docker run command essentially runs the command below in the registry:2 Docker container

htpasswd -Bbn testuser testpassword

and then redirect the output the file auth/htpasswd in your local directory

Update: To run the command htpasswd -Bbn testuser testpassword > auth/htpasswd (with redirection) in the container. You can run it as a /bin/sh command instead with the redirection included

docker run \
  registry:2 /bin/sh -c "htpasswd -Bbn testuser testpassword > auth/htpasswd" 

If auth is not found in the directory, you can create it before running the htpasswd command

docker run \
  registry:2 /bin/sh -c "mkdir -p auth && htpasswd -Bbn testuser testpassword > auth/htpasswd" 

All docker args come before the image name; those args are for htpasswd, which is the .. yup, you guessed it, the “entry point”.

The htpasswd args mean use bcrypt, run in batch, use standard output.

Related