Docker htpasswd 生成密码对

2 min read
docker run --rm -it --entrypoint /usr/local/apache2/bin/htpasswd httpd:alpine -nb admin password

也可以直接使用命令行

echo $(htpasswd -nB user) | sed -e s/\\$/\\$\\$/g

还要注意,美元符号在未计算时不应加倍(例如Ansible docker_container模块)

报错如下:

WARNING: The apr1 variable is not set. Defaulting to a blank string.