把自己commit后的docker镜像上传到阿里云并拉取测试

一、首先有自己的本地创建镜像(根据已有的容器进行创建,该容器可以根据自己的环境需求下载相应的服务及配置)

docekr commit -m="描述信息" -a="作者" [容器ID] 要创建的目标镜像名:[标签名]

docekr commit -m="自定义redis" -a="wt" 84e6494e131b myredis:1.0

二、将镜像推送到阿里云镜像仓库,登录时需要输入设置的密码(打开阿里云->搜索”容器镜像服务”->管理控制台->个人实例->命名空间,直接链接访问)

点击 访问凭证 并设置密码(向阿里云推送镜像需要单独设置密码)

1、首选创建命名空间

 

 

2、然后创建镜像仓库

 

创建成功跳转链接,然后展示的都是阿里云自动生成的脚本命令,只需在使用的时候拷贝粘贴即可。

 

3、进入管理界面获得脚本

  

 4、登录,docker login --username=[用户名] registry.cn-hangzhou.aliyuncs.com

docker login --username=aliyun6177156708 registry.cn-hangzhou.aliyuncs.com //我的登录username

然后输入密码 (访问凭证)

可能遇到报错----------start-----

Error response from daemon: Get "https://registry.cn-hangzhou.aliyuncs.com/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

解决报错------

可能是ping不通 registry.cn-hangzhou.aliyuncs.com 、 dockerauth.cn-hangzhou.aliyuncs.com

ping registry.cn-hangzhou.aliyuncs.com   ping dockerauth.cn-hangzhou.aliyuncs.com

修改配置

vim /etc/resolv.conf
# Generated by NetworkManager
search localdomain
#nameserver 192.168.63.2
nameserver 223.5.5.5 //改为 223.5.5.5

可能遇到报错----------end-----

5、docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/[命名空间的名称]/[镜像名称]:[镜像版本号]

docker tag 84e6494e131b registry.cn-hangzhou.aliyuncs.com/wt15712953567/test:1.0

6、推送到仓库,docker push registry.cn-hangzhou.aliyuncs.com/wt15712953567/test:[镜像版本号]

 docker push registry.cn-hangzhou.aliyuncs.com/wt15712953567/test:1.0
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/wt15712953567/test]
171d10a17c74: Layer already exists 
b86f5af04cbc: Layer already exists 
f77aaa5563c7: Layer already exists 
3fd943d71831: Layer already exists 
5a6f7dd04968: Layer already exists 
279a4748211b: Layer already exists 
fd95118eade9: Layer already exists 
1.0: digest: sha256:254493a1e4be92f161260212b61b1ddb5d99513dc3d8f2491aa51e65d0f96be3 size: 1780

推送成功

三、拉取阿里云中的镜像

 删除本地镜像

[root@localhost ~]# docker rmi -f 84e6494e131b 
Untagged: wt_redis:6.3.1
Untagged: registry.cn-hangzhou.aliyuncs.com/wt15712953567/my_redis:1.0
Untagged: registry.cn-hangzhou.aliyuncs.com/wt15712953567/test:1.0
Untagged: registry.cn-hangzhou.aliyuncs.com/wt15712953567/test@sha256:254493a1e4be92f161260212b61b1ddb5d99513dc3d8f2491aa51e65d0f96be3
Deleted: sha256:84e6494e131bd285135ac97a39d05d27cc829235db41be61b311d25ed782cba8

 

 拉取,docker pull registry.cn-hangzhou.aliyuncs.com/wt15712953567/test:[镜像版本号]

[root@localhost ~]# docker pull registry.cn-hangzhou.aliyuncs.com/wt15712953567/test:1.0  //指定版本号
1.0: Pulling from wt15712953567/test
214ca5fb9032: Already exists 
9eeabf2ad250: Already exists 
b8eb79a9f3c4: Already exists 
3956405ca492: Already exists 
795ff1010e48: Already exists 
a3b05d56b939: Already exists 
dd4d097a94e6: Already exists 
Digest: sha256:254493a1e4be92f161260212b61b1ddb5d99513dc3d8f2491aa51e65d0f96be3
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/wt15712953567/test:1.0
registry.cn-hangzhou.aliyuncs.com/wt15712953567/test:1.0

 运行测试

[root@localhost ~]# docker run -it 84e6494e131b /bin/bash
root@a3b596752cdf:/data#  
posted @ 2022-06-08 17:00  温柔的风  阅读(543)  评论(0编辑  收藏  举报