四、本地镜像发布到阿里云

发布于:2024-07-01 ⋅ 阅读:(15) ⋅ 点赞:(0)

目录

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

二、镜像的生成方法

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


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

二、镜像的生成方法

1、第三章使用的 commit 方法

2、Dockerfile的方法,后续讲解

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

1、登录阿里云

2、选择控制台,进入容器镜像服务

3、选择个人实例

4、创建命名空间

5、创建镜像仓库

 

 

 

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

[root@localhost ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
wu/ubuntu     1.1       a32a52da6413   20 hours ago   177MB
wu/ubuntu     latest    9fd000d64b52   46 hours ago   72.8MB
redis         latest    7614ae9453d1   2 years ago    113MB
ubuntu        latest    ba6acccedd29   2 years ago    72.8MB
hello-world   latest    feb5d9fea6a5   2 years ago    13.3kB
[root@localhost ~]# 

[root@localhost ~]# docker login --username=aliyun9421012936 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 ~]# 
[root@localhost ~]# docker tag a32a52da6413 registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu:1.1
[root@localhost ~]# 
[root@localhost ~]# docker push registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu:1.1
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu]
fd9600ce66a0: Pushed 
fcdbee711a3d: Pushed 
1.1: digest: sha256:2ffb01e77cbd8c65ab27417a8733818fd05f0897de10751c637c392d2219e4b0 size: 741
[root@localhost ~]#

上传完之后,为了验证,需要把本地的镜像删除,从阿里云拉取测试
[root@localhost ~]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED        SIZE
wu/ubuntu                                                  1.1       a32a52da6413   20 hours ago   177MB
registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu   1.1       a32a52da6413   20 hours ago   177MB
wu/ubuntu                                                  latest    9fd000d64b52   46 hours ago   72.8MB
redis                                                      latest    7614ae9453d1   2 years ago    113MB
ubuntu                                                     latest    ba6acccedd29   2 years ago    72.8MB
hello-world                                                latest    feb5d9fea6a5   2 years ago    13.3kB
[root@localhost ~]# 

[root@localhost ~]# docker rmi -f a32a52da6413
Untagged: wu/ubuntu:1.1
Untagged: registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu:1.1
Untagged: registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu@sha256:2ffb01e77cbd8c65ab27417a8733818fd05f0897de10751c637c392d2219e4b0
Deleted: sha256:a32a52da64130f18a01cb0f1a228e87e203fe08738bd651ff616d4c2e564666f
Deleted: sha256:7e6257efdd107305b9c3e816d52e86104601e79c1e32324e55d0560976f75c4a
[root@localhost ~]# 
#拉取镜像
[root@localhost ~]# docker pull registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu:1.1
1.1: Pulling from wuzhaobo_test/myubuntu
3ad9c1e2849d: Already exists 
2e2e4f44b383: Pull complete 
Digest: sha256:2ffb01e77cbd8c65ab27417a8733818fd05f0897de10751c637c392d2219e4b0
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu:1.1
registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu:1.1
[root@localhost ~]# 
[root@localhost ~]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED        SIZE
registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu   1.1       a32a52da6413   21 hours ago   177MB
wu/ubuntu                                                  latest    9fd000d64b52   46 hours ago   72.8MB
redis                                                      latest    7614ae9453d1   2 years ago    113MB
ubuntu                                                     latest    ba6acccedd29   2 years ago    72.8MB
hello-world                                                latest    feb5d9fea6a5   2 years ago    13.3kB
[root@localhost ~]# 
[root@localhost ~]# docker run -it a32a52da6413 /bin/bash
root@1f4beccfdf0e:/# 
root@1f4beccfdf0e:/# cd /tmp/
root@1f4beccfdf0e:/tmp# vim a.txt 
root@1f4beccfdf0e:/tmp# 
root@1f4beccfdf0e:/tmp# cat a.txt 
this is docker
 hello
root@1f4beccfdf0e:/tmp#