第五章本地镜像发布到阿里云

导读:本篇文章讲解 第五章本地镜像发布到阿里云,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

1、本地镜像发布到阿里云流程

在这里插入图片描述

2、镜像的生成方法

上一讲已经介绍过 基于当前容器创建一个新的镜像,新功能增强 docker commit [OPTIONS] 容器ID [REPOSITORY[:TAG]]

OPTIONS说明: -a :提交的镜像作者; -m :提交时的说明文字;

后面的DockerFile章节,第2种方法

3、将本地镜像推送到阿里云

1、本地镜像素材原型就是上次的test/myubuntu
[root@localhost ~]# docker images
REPOSITORY      TAG          IMAGE ID       CREATED         SIZE
test/myubuntu   1.3          8d4088598f0b   7 minutes ago   176MB

2、地址:
3、创建仓库镜像

3.1、选择控制台,进入容器镜像服务 3.2、选择个人实例 3.3、命名空间 3.3.1、继续 3.4、仓库名称 3.4.1、继续 3.5、进入管理界面获得脚本

4、将镜像推送到阿里云

将镜像推送到阿里云registry 管理界面脚本 在这里插入图片描述

脚本实例

登录
$ docker login --username=用户名 registry.cn-hangzhou.aliyuncs.com
$ docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu:[镜像版本号]
$ docker push registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu:[镜像版本号]
[root@localhost ~]# docker images
REPOSITORY      TAG          IMAGE ID       CREATED          SIZE
test/myubuntu   1.3          8d4088598f0b   57 minutes ago   176MB
rabbitmq        management   6c3c2a225947   3 months ago     253MB
ubuntu          latest       ba6acccedd29   5 months ago     72.8MB
redis           6.0.8        16ecd2772934   17 months ago    104MB
[root@localhost ~]# docker login --username=用户名 registry.cn-hangzhou.aliyuncs.com
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@localhost ~]# docker tag 8d4088598f0b registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu:1.3
[root@localhost ~]# docker push registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu:1.3
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu]
0842f0f465f6: Pushed 
9f54eef41275: Pushed 
1.3: digest: sha256:b794a18c1a0a6f537f3f57c507024b1f80373cedb4eb2a94f44f7d30febb56b3 size: 741
[root@localhost ~]# 

4、将阿里云上的镜像下载到本地

为了验证我们先把我们本地的test/myubuntu 删除

[root@localhost ~]# docker images
REPOSITORY                                                TAG          IMAGE ID       CREATED             SIZE
test/myubuntu                                             1.3          8d4088598f0b   About an hour ago   176MB
registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu   1.3          8d4088598f0b   About an hour ago   176MB
rabbitmq                                                  management   6c3c2a225947   3 months ago        253MB
ubuntu                                                    latest       ba6acccedd29   5 months ago        72.8MB
redis                                                     6.0.8        16ecd2772934   17 months ago       104MB
[root@localhost ~]# docker rmi -f 8d4088598f0b
Untagged: test/myubuntu:1.3
Untagged: registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu:1.3
Untagged: registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu@sha256:b794a18c1a0a6f537f3f57c507024b1f80373cedb4eb2a94f44f7d30febb56b3
Deleted: sha256:8d4088598f0b97f5479a82459f6c82edacb4fcb3a3a0c0ef829117c616c9a935
[root@localhost ~]# docker images
REPOSITORY   TAG          IMAGE ID       CREATED         SIZE
rabbitmq     management   6c3c2a225947   3 months ago    253MB
ubuntu       latest       ba6acccedd29   5 months ago    72.8MB
redis        6.0.8        16ecd2772934   17 months ago   104MB


从阿里云仓库拉取镜像

[root@localhost ~]# docker pull registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu:1.3
1.3: Pulling from testshanghai/myubuntu
7b1a6ab2e44d: Already exists 
74a377d6a202: Already exists 
Digest: sha256:b794a18c1a0a6f537f3f57c507024b1f80373cedb4eb2a94f44f7d30febb56b3
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu:1.3
registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu:1.3
[root@localhost ~]# docker images
REPOSITORY                                                TAG          IMAGE ID       CREATED             SIZE
registry.cn-hangzhou.aliyuncs.com/testshanghai/myubuntu   1.3          8d4088598f0b   About an hour ago   176MB
rabbitmq                                                  management   6c3c2a225947   3 months ago        253MB
ubuntu                                                    latest       ba6acccedd29   5 months ago        72.8MB
redis                                                     6.0.8        16ecd2772934   17 months ago       104MB
[root@localhost ~]# docker run -it 8d4088598f0b /bin/bash
root@4a79a3ae9391:/# 
root@4a79a3ae9391:/# vim a.txt
root@4a79a3ae9391:/# cat a.txt
docker holle world !
root@4a79a3ae9391:/# exit
exit
[root@localhost ~]# 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/1319.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!