Search code examples
dockerdocker-registry

what does "-Bbn" means in Docker?


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?


Solution

  • -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"