docker学习笔记(二)——本地私有仓库Registry的搭建与验证
Registry的部署 获取registry镜像 1 #dockerpullregistry:2.1.1 启动registry容器 1 2 3 4 5 6 7 8 9 #dockerrun-d-v/opt/registry:/var/lib/registry-p5000:5000--restart=always--nameregistryregistry:2.1.1 查看进程 #dockerps CONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMES ac291ed888feregistry:2.1.1 "/bin/registry/et..." 27minutesagoUp27minutes0.0.0.0:5000->5000 /tcp registry 验证服务是否正常 #curlhttp://127.0.0.1:5000/v2/ {} 上传镜像 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 查看本地已有镜像 #dockerimages REPOSITORYTAGIMAGEIDCREATEDSIZE nginxv2570d531c994a4hoursago107MB nginxlatestb8efb18f159b3weeksago107MB centos6.80cd976dc0a9811monthsago195MB registry2.1.152bb991b482e22monthsago220MB 创建dockertag镜像 #dockertagnginx:v2127.0.0.1:5000/nginx:v2 即用ningx:v2创建127.0.0.1:5000 /nginx :v2的镜像 #dockerimages REPOSITORYTAGIMAGEIDCREATEDSIZE 127.0.0.1:5000 /nginx v2570d531c994a4hoursago107MB nginxv2570d531c994a4hoursago107MB nginxlatestb8efb18f159b3weeksago107MB centos6.80cd976dc0a9811monthsago195MB registry2.1.152bb991b482e22monthsago220MB push镜像到本地仓库 #dockerpush127.0.0.1:5000/nginx:v2 Thepushreferstoarepository[127.0.0.1:5000 /nginx ] 04a8761254c7:Pushed af5bd3938f60:Pushed 29f11c413898:Pushed eb78099fbf7f:Pushed v2:digest:sha256:9586184eb142f8c66decfd4fd7b3a2b54abfcb0f0a25541e69ba3725c61ba8b3size:8522 查看是否已经上传 #curlhttp://192.168.12.109:5000/v2/_catalog { "repositories" :[ "nginx" ]} 下载镜像 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 先删除已经有的镜像 [root@DockServeropt] #dockerimages REPOSITORYTAGIMAGEIDCREATEDSIZE 127.0.0.1:5000 /nginx v2570d531c994a4hoursago107MB nginxv2570d531c994a4hoursago107MB nginxlatestb8efb18f159b3weeksago107MB centos6.80cd976dc0a9811monthsago195MB registry2.1.152bb991b482e22monthsago220MB [root@DockServeropt] #dockerrmi-f570d531c994a Untagged:127.0.0.1:5000 /nginx :v2 Untagged:127.0.0.1:5000 /nginx @sha256:9586184eb142f8c66decfd4fd7b3a2b54abfcb0f0a25541e69ba3725c61ba8b3 Untagged:nginx:v2 Deleted:sha256:570d531c994a495b7cba536ac12f9d640141cbbaecd9ae8a114816681a8ca750 Deleted:sha256:f4a3f9102faadf3e941a05724ffe69e3aa3dc1fee5de3762c374ee337a27d60b [root@DockServeropt] #dockerimages REPOSITORYTAGIMAGEIDCREATEDSIZE nginxlatestb8efb18f159b3weeksago107MB centos6.80cd976dc0a9811monthsago195MB registry2.1.152bb991b482e22monthsago220MB 确定已经删除后,我们下载 [root@DockServeropt] #dockerpull127.0.0.1:5000/nginx:v2 v2:Pullingfromnginx 94ed0c431eb5:Alreadyexists 9406c100a1c3:Alreadyexists aa74daafd50c:Alreadyexists 79afb5d63c06:Pullcomplete Digest:sha256:9586184eb142f8c66decfd4fd7b3a2b54abfcb0f0a25541e69ba3725c61ba8b3 Status:Downloadednewerimage for 127.0.0.1:5000 /nginx :v2 [root@DockServeropt] #dockerimages REPOSITORYTAGIMAGEIDCREATEDSIZE 127.0.0.1:5000 /nginx v2d296335af0a94hoursago107MB nginxlatestb8efb18f159b3weeksago107MB centos6.80cd976dc0a9811monthsago195MB registry2.1.152bb991b482e22monthsago220MB 可以看到已经本地仓库 可以成功上传 下载镜像了 本文转自 jackjiaxiong 51CTO博客,原文链接:http://blog.51cto.com/xiangcun168/1957392