1. Docker 仓库认证机制以及镜像上传拉取
首先需要创建认证文件:
[root@lockey6 ~]# mkdir /opt/auth
[root@lockey6 ~]# docker run --entrypoint htpasswd registry:latest -Bbn root lockey23 > /opt/auth/htpasswd
[root@lockey6 ~]# cat /opt/auth/htpasswd
root:$2y$05$Q9UC6TgtNnfeD5IambUW4eckWSL7E.Zq9SJ.MKkUSDSnA5y2/IUn2
然后以认证方式运行registry容器
[root@lockey6 ~]# docker run -d --name registry -p 5000:5000 -v /opt/registry:/var/lib/registry -v /opt/auth:/auth -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" registry:latest
895934bca5b54843fb0f6b6848fd6b2a4832d7b271143867acf4aa5b3fe61346
未进行认证不能执行操作,认证后执行成功
上传本地镜像并且删除本地镜像,然后从仓库中pull下来