为什么用阿里云
docker有自己的仓库服务器,但是对没掏钱的(白嫖)用户并不是那么友好,有两个很大的限制:
免费用户,在6个月之内如果没有任何操作,将会被自动删除,真的很糟糕啊。
匿名用户在 6 个小时之内,只能进行 100 次拉取;
免费的注册用户在 6 个小时之内,只能进行 200 次拉取;
收费用户则没有限制,5美元一个月。
鉴于此,用阿里云还是比较友好的,没有上面的限制,当然阿里云也有一些收费的服务条款,普通用户应该也不需要。
阿里云下基本操作
没有阿里云的先去注册一个注册阿里云。然后进到容器镜像服务下,进入管理控制台。


创建个人实例:

创建一个命名空间,这里面是我们的仓库镜像

设置下固定密码,docker登陆的时候会用到。

docker下登录阿里云
回到虚拟机下,登录阿里云
sudo docker login --username=muaxi8 registry.cn-beijing.aliyuncs.com
输入密码后会提示密码保存在目录: /root/.docker/config.json.
网上有说下次登录不用再输入密码,试了下,每次都要输入密码的。

创建镜像仓库;
这里随便创建一个仓库,用于测试

点击仓库进去后,可以看到阿里云仓库推送,拉取的指南,没什么技术,照着做就行。

docker上传镜像操作
上传操作:
root@ubuntu:~# docker tag ubuntu:v1 registry.cn-beijing.aliyuncs.com/muchx/as:v1
root@ubuntu:~#
root@ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu v1 ac5656a14d3b 2 days ago 135MB
registry.cn-beijing.aliyuncs.com/muchx/as registry.cn-beijing.aliyuncs.com/muchx/as v1 ac5656a14d3b 2 days ago 135MB
ubuntu 16.04 b6f507652425 16 months ago 135MB
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~# docker push registry.cn-beijing.aliyuncs.com/muchx/as:v1
The push refers to repository [ registry.cn-beijing.aliyuncs.com/muchx/as]
1251204ef8fc: Pushed
47ef83afae74: Pushed
df54c846128d: Pushed
be96a3f634de: Pushed
v1: digest: sha256:494a8c3648370200333a32bc7f0d3bedad4966f0de8d894be91957dac58b33fc size: 1150
root@ubuntu:~#
root@ubuntu:~# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu v1 ac5656a14d3b 2 days ago 135MB
registry.cn-beijing.aliyuncs.com/muchx/as v1 ac5656a14d3b 2 days ago 135MB
ubuntu 16.04 b6f507652425 16 months ago 135MB
阿里云上查看上传的镜像,id好也是能对上的。

自动创建镜像实验
如果不创建镜像仓库,上传的时候指定仓库名称会自动创建的。做个实验,先删除阿里云上刚创建的镜像仓库:

docker下执行上传操作:
root@ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu v1 ac5656a14d3b 2 days ago 135MB
ubuntu 16.04 b6f507652425 16 months ago 135MB
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~# docker tag ubuntu:v1 registry.cn-beijing.aliyuncs.com/muchx/ubuntu:v1
root@ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu v1 ac5656a14d3b 2 days ago 135MB
registry.cn-beijing.aliyuncs.com/muchx/ubunturegistry.cn-beijing.aliyuncs.com/muchx/ubuntu v1 ac5656a14d3b 2 days ago 135MB
ubuntu 16.04 b6f507652425 16 months ago 135MB
root@ubuntu:~#
root@ubuntu:~# docker push registry.cn-beijing.aliyuncs.com/muchx/ubuntu:v1
The push refers to repository [ registry.cn-beijing.aliyuncs.com/muchx/ubuntu]
1251204ef8fc: Pushed
47ef83afae74: Pushed
df54c846128d: Pushed
be96a3f634de: Pushed
v1: digest: sha256:494a8c3648370200333a32bc7f0d3bedad4966f0de8d894be91957dac58b33fc size: 1150
root@ubuntu:~#
阿里云下查看自动创建的镜像:

转载:https://blog.csdn.net/muaxi8/article/details/128658684
查看评论