资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

7.docker-registry私有仓库

1.下载私有仓库镜像

成都创新互联是一家专注网站建设、网络营销策划、微信小程序定制开发、电子商务建设、网络推广、移动互联开发、研究、服务为一体的技术型公司。公司成立十载以来,已经为成百上千家隧道混凝土搅拌车各业的企业公司提供互联网服务。现在,服务的成百上千家客户与我们一路同行,见证我们的成长;未来,我们一起分享成功的喜悦。

[root@docker03 ~]# docker pull registry 
Using default tag: latest
latest: Pulling from library/registry
c87736221ed0: Pull complete 
1cc8e0bb44df: Pull complete 
54d33bcb37f5: Pull complete 
e8afc091c171: Pull complete 
b4541f6d3db6: Pull complete 
Digest: sha256:8004747f1e8cd820a148fb7499d71a76d45ff66bac6a29129bfdbfdc0154d146
Status: Downloaded newer image for registry:latest
docker.io/library/registry:latest

2.启动镜像

[root@docker03 ~]# docker run -d -p 5000:5000 --restart=always --name registry -v /opt/myregistry:/var/lib/registry registry
c167a59c546c90e32bd0f15cc9b219555056d89b0f09af61f4b0e0ae8d930a82

3.第一次上传报错

[root@docker03 ~]# docker tag centos:7 10.0.0.13:5000/centos:7

[root@docker03 ~]# docker push 10.0.0.13:5000/centos

The push refers to repository [10.0.0.13:5000/centos]

Get https://10.0.0.13:5000/v2/: http: server gave HTTP response to HTTPS client

4.默认是http,添加信任(文件默认是没有的)

vim /etc/docker/daemon.json
{
  "insecure-registries": ["10.0.0.13:5000"]
}
#重启docker
systemctl  restart docker

5.上传(push)镜像测试

root@docker03 ~]# docker push 10.0.0.13:5000/centos:6.9 
The push refers to repository [10.0.0.13:5000/cnetos]
aaa5621d7c01: Pushed 

6.下载(pull)镜像测试

[root@docker03 ~]# docker pull  10.0.0.13:5000/centos:6.9   

7.删除私有仓库中的镜像

#进入私有仓库registry
[root@docker03 ~]# docker exec -it registry /bin/sh
#删除repo
~ # rm -rf /var/lib/registry/docker/registry/v2/repositories/cnetos
#清楚掉blob
~ # registry garbage-collect /etc/docker/registry/config.yml

8.把registry加认证

[root@docker03 ~]# yum install httpd-tools -y
[root@docker03 ~]# mkdir /opt/registry-var/auth/ -p
[root@docker03 ~]# htpasswd -Bbn shuai 123456 >> /opt/registry-var/auth/htpasswd
[root@docker03 ~]# docker run -d -p 5000:5000 -v /opt/registry-var/auth/:/auth/ -v /opt/myregistry:/var/lib/registry -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd registry
#没有认证无法上传
[root@docker03 ~]# docker tag centos:latest 10.0.0.13:5000/centos:7           
[root@docker03 ~]# docker push 10.0.0.13:5000/centos:7 
The push refers to repository [10.0.0.13:5000/centos]
9e607bb861a7: Preparing 
no basic auth credentials
#登陆上传
[root@docker03 ~]# docker login 10.0.0.13:5000
Username: shuai    
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@docker03 ~]# docker push 10.0.0.13:5000/centos:7 
The push refers to repository [10.0.0.13:5000/centos]
9e607bb861a7: Pushed 
7: digest: sha256:6ab380c5a5acf71c1b6660d645d2cd79cc8ce91b38e0352cbf9561e050427baf size: 529
#登出
[root@docker03 ~]# docker logout 10.0.0.13:5000
Removing login credentials for 10.0.0.13:5000

9.密码文件目录

[root@docker03 ~]# cat /root/.docker/config.json 
{
    "auths": {
        "10.0.0.13:5000": {
            "auth": "c2h2YWk6MTIzNDU2"
        }
    },
    "HttpHeaders": {
        "User-Agent": "Docker-Client/19.03.3 (linux)"
    }
#使用base64认证c2h2YWk6MTIzNDU2=shuai:123456

当前名称:7.docker-registry私有仓库
转载源于:http://cdkjz.cn/article/pjhhgs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220