docker私有仓库的搭建与使用

docker私有仓库的搭建与使用

一、私有仓库的优点:

其实,私有库的镜像最原始来源还是从公库中下载的,但是企业公司中为什么不都直接使用公库下载需要的镜像呢,允许使用 registry 搭建本地私有仓库,具备这些公库不具备的优点:

1、节省网络带宽,针对于每个镜像不用每个人都去中央仓库上面去下载,只需要从私有仓库中下载即可;

2、提供镜像资源利用,针对于公司内部使用的镜像,推送到本地的私有仓库中,以供公司内部相关人员使用。

二、私有仓库搭建

#下载私有库镜像docker pull registry#在文件中添加地址为私有仓库ip地址vim /etc/docker/daemon.json {"registry-mirrors":["https://coub04fo.mirror.aliyuncs.com","https://f1361db2.m.daocloud.io/","https://registry.docker-cn.com/","https://docker.mirrors.ustc.edu.cn/","https://hub-mirror.c.163.com/"],#私有仓库地址"insecure-registries":["192.168.1.10:5000"]}#重载配置和重启dockersystemctl daemon-reload  && systemctl restart docker#启动私有仓库docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --name registry  registry

三、私有仓库的使用

#查看仓库中的镜像curl -XGET http://192.168.1.10:5000/v2/_catalog{"repositories":[]}#打包镜像docker tag  centos:latest  192.168.1.10:5000/centos#上传镜像docker push 192.168.1.10:5000/centos#查看仓库中的镜像curl -XGET http://192.168.1.10:5000/v2/_catalog{"repositories":["centos"]}

四、docker私有仓库增加web访问

#下载web界面镜像docker pull hyper/docker-registry-web#启动webui同时连接仓库docker run -dit --restart=always -p 8080:8080 --name registry-web --link registry -e REGISTRY_URL=http://192.168.1.10:5000/v2 -e REGISTRY_NAME=localhost:5000 hyper/docker-registry-web访问web界面http://192.168.1.10:8080/

图片

五、测试上传下载与web界面是否存在镜像

上传

[root@localhost ~]# docker tag registry:latest 192.168.1.10:5000/registry:latest[root@localhost ~]# docker push 192.168.1.10:5000/registry:latestThe push refers to repository [192.168.1.10:5000/registry]aeccf26589a7: Pushed f640be0d5aad: Pushed aa4330046b37: Pushed ad10b481abe7: Pushed 69715584ec78: Pushed latest: digest: sha256:36cb5b157911061fb610d8884dc09e0b0300a767a350563cbfd88b4b85324ce4 size: 1363

图片

下载

#查看镜像docker images#docker下载仓库中的镜像docker pull 192.168.1.10:5000/centos:latest#查看镜像docker images

图片

收录于合集 #docker
 2
上一篇Docker的部署与基础操作
阅读 505
凉兮的运维日记
22篇原创内容
 
 
posted @ 2023-07-13 17:18  往事已成昨天  阅读(511)  评论(0编辑  收藏  举报