Docker 仓库用户登录认证示例

[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

相关推荐
景天科技苑1 小时前
【云原生开发】K8S多集群资源管理平台架构设计
云原生·容器·kubernetes·k8s·云原生开发·k8s管理系统
wclass-zhengge1 小时前
K8S篇(基本介绍)
云原生·容器·kubernetes
颜淡慕潇2 小时前
【K8S问题系列 |1 】Kubernetes 中 NodePort 类型的 Service 无法访问【已解决】
后端·云原生·容器·kubernetes·问题解决
川石课堂软件测试4 小时前
性能测试|docker容器下搭建JMeter+Grafana+Influxdb监控可视化平台
运维·javascript·深度学习·jmeter·docker·容器·grafana
昌sit!10 小时前
K8S node节点没有相应的pod镜像运行故障处理办法
云原生·容器·kubernetes
追风林11 小时前
mac 本地docker-mysql主从复制部署
mysql·macos·docker
A ?Charis12 小时前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
城南vision13 小时前
Docker学习—Docker核心概念总结
java·学习·docker
wclass-zhengge13 小时前
Docker篇(Docker Compose)
运维·docker·容器
北漂IT民工_程序员_ZG13 小时前
k8s集群安装(minikube)
云原生·容器·kubernetes