背景
我们可以像使用github一样使用阿里云远程镜像库,进行镜像的推送、拉取等操作
使用方法
把本地镜像推送到阿里云
1)、登录阿里云开发者平台 http://dev.aliyun.com,然后点击控制台,搜索容器镜像服务
2)、创建镜像仓库,输入命名空间(没有自动创建)、仓库名、摘要,点击下一步指定代码源为本地仓库即可
3)、然后按照弹出来的操作指南进行推送即可(命令前面不用加sudo),以下为实例
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mycentos 1.2 2ad0dab56fc5 16 seconds ago 327MB
myip_son latest 770b567e828f About an hour ago 277MB
myip latest 7d6ca7ebc988 About an hour ago 263MB
szc_centos latest 57bd622f6cb2 2 hours ago 327MB
szc/tomcat 1.1 6d1afa72732c 8 hours ago 529MB
mysql 5.6 c8078e8ab06d 3 days ago 303MB
tomcat latest 4e7840b49fad 10 days ago 529MB
centos latest 470671670cac 7 weeks ago 237MB
scrapinghub/splash latest 4ddd2efcb0df 8 weeks ago 2.17GB
$ docker login --username=szc registry.cn-beijing.aliyuncs.com
Password:
Login Succeeded
$ docker tag 2ad0dab56fc5 registry.cn-beijing.aliyuncs.com/songzeceng/mycentos:1.2
$ docker push registry.cn-beijing.aliyuncs.com/songzeceng/mycentos:1.2
The push refers to repository [registry.cn-beijing.aliyuncs.com/songzeceng/mycentos]
fe6076440ddc: Pushed
c5cfb0f8a420: Pushed
0683de282177: Pushed
1.2: digest: sha256:5f127cd8a6db0eb87d07681b7132c43914f5a313a579407d63b2c343fb01f92f size: 953
然后就可以在镜像搜索栏里搜索我们的镜像songzeceng.mycentos了
也可以在我们的仓库里看到这个镜像
从阿里云上拉取镜像
从上面两种查找镜像的结果界面里,点击我们的镜像,都可以看到镜像的公网地址
复制公网地址,然后docker pull即可
$ docker pull registry.cn-beijing.aliyuncs.com/songzeceng/mycentos:1.2
1.2: Pulling from songzeceng/mycentos
8a29a15cefae: Already exists
f8b350b52292: Already exists
f203bf770354: Already exists
Digest: sha256:5f127cd8a6db0eb87d07681b7132c43914f5a313a579407d63b2c343fb01f92f
Status: Downloaded newer image for registry.cn-beijing.aliyuncs.com/songzeceng/mycentos:1.2
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.cn-beijing.aliyuncs.com/songzeceng/mycentos 1.2 2ad0dab56fc5 22 minutes ago 327MB
myip_son latest 770b567e828f 2 hours ago 277MB
myip latest 7d6ca7ebc988 2 hours ago 263MB
szc_centos latest 57bd622f6cb2 2 hours ago 327MB
szc/tomcat 1.1 6d1afa72732c 8 hours ago 529MB
mysql 5.6 c8078e8ab06d 3 days ago 303MB
tomcat latest 4e7840b49fad 10 days ago 529MB
centos latest 470671670cac 7 weeks ago 237MB
scrapinghub/splash latest 4ddd2efcb0df 8 weeks ago 2.17GB