[root@docker ~]# mkdir auth
[root@docker ~]# htpasswd -Bc auth/.htpasswd folian
New password:
Re-type new password:
Adding password for user folian
[root@docker ~]# cat auth/.htpasswd
folian:$2y05j.zeXhTzsLRDuNy.pjATteJWCLzne//ce.gFUOXX4/LdKnmFqFH92
[root@docker ~]#
[root@docker ~]# htpasswd -B auth/.htpasswd admin
New password:
Re-type new password:
Adding password for user admin
[root@docker ~]# cat auth/.htpasswd
admin:$2y05ZcNbQW./n0iYGj828W4WfePZsBMEPceoQb1i26ogQA72K9KWe7mpe
##建立好了后,如何使得镜像仓库能识别这个文件?
[root@docker ~]# docker run -d -p 443:443 --restart=always --name registry \> --name registry -v /opt/registry:/var/lib/registry \> -v /root/certs:/certs \ > -e REGISTRY_HTTP_ADDR=0.0.0.0:443 \
> -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/folian.org.crt \
> -e REGISTRY_HTTP_TLS_KEY=/certs/folian.org.key \
> -v /root/auth:/auth \
> -e "REGISTRY_AUTH=htpasswd" \
> -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
> -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
> registry
推送上传镜像:失败:因为没登录
[root@docker ~]# docker tag nginx:latest reg.folian.org/nginx:latest
[root@docker ~]# docker push reg.folian.org/nginx:latest
登录
#遇到报错:
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES #问题所在!!参数写错了
6e290f11a2c4 registry "/entrypoint.sh -v /..." 7 minutes ago Restarting (0) 35 seconds ago registry
[root@docker ~]# docker rm -f registry
registry
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@docker ~]#
修改:[root@docker ~]# docker run -d -p 443:443 --restart=always -v /root/certs:/certs -e REGISTRY_HTTP_ADDR=0.0.0.0:443 -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/folian.org.crt -e REGISTRY_HTTP_TLS_KEY=/certs/folian.org.key -v /root/auth:/auth -e REGISTRY_AUTH=htpasswd -e REGISTRY_AUTH_HTPASSWD_REALM="Registry Realm" -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/.htpasswd registry
2119f030f213104619290b6c41313fcd8d5b9dd6daed465dbef7c15be726ec90
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2119f030f213 registry "/entrypoint.sh /etc..." 7 seconds ago Up 6 seconds 0.0.0.0:443->443/tcp, :::443->443/tcp, 5000/tcp suspicious_jepsen