文章目錄
- 1、準備鏡像
- 2、建立命名空間
- 3、建立鏡像倉庫
- 4、推送鏡像
1、準備鏡像
[root@localhost ~]# docker pull centos
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 300e315adb2f 4 months ago 209MB
[root@localhost ~]# docker run -it centos
[root@70373a4e86f2 /]#
[root@70373a4e86f2 /]# [root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
70373a4e86f2 centos "/bin/bash" 12 seconds ago Up 11 seconds eager_knuth
[root@localhost ~]# docker commit -a zuoxuchen -m "zuoxuchen_test_docker_centos_last" 70373a4e86f2 zuoxuchen_centos:1.4
sha256:57c8e3e58d02dbb14e3722a95ce24176d9dc85b713a7f413d6a2d4cb33ef0650
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zuoxuchen_centos 1.4 57c8e3e58d02 5 seconds ago 209MB
centos latest 300e315adb2f 4 months ago 209MB
2、建立命名空間
打開阿裡雲官網,搜尋【容器鏡像服務】;
打開網頁【倉庫管理】-【命名空間】-【建立命名空間】,由于我是使用過,是以提前建立好了兩個命名空間,新使用者是需要自己建立的;
建立一個新的命名空間,并賦予其名稱,每一個賬戶可以擁有三個命名空間(一個公有,一個私有就足夠我們使用了);
建立完成後可以修改倉庫類型為公有還是私有,此處需要使用公有類型;
3、建立鏡像倉庫
打開【倉庫管理】-【鏡像倉庫】-【建立鏡像倉庫】
配置新建立的鏡像倉庫,指令空間可以進行選擇為公開還是私有,地域預設為
4、推送鏡像
點選建立好的鏡像倉庫中的【管理】;
使用第三節的内容進行鏡像推送,内容如下;
$ sudo docker login --username=左旭晨 registry.cn-hangzhou.aliyuncs.com
$ sudo docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/zuoxuchen/docker_test:[鏡像版本号]
$ sudo docker push registry.cn-hangzhou.aliyuncs.com/zuoxuchen/docker_test:[鏡像版本号]
此處為root使用者權限,不需要sudo提權指令,下述全部省略;
[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 images
REPOSITORY TAG IMAGE ID CREATED SIZE
zuoxuchen_centos 1.4 57c8e3e58d02 5 minutes ago 209MB
centos latest 300e315adb2f 4 months ago 209MB
[root@localhost ~]# docker tag 57c8e3e58d02 registry.cn-hangzhou.aliyuncs.com/zuoxuchen/docker_test:1.4.1
[root@localhost ~]# docker push registry.cn-hangzhou.aliyuncs.com/zuoxuchen/docker_test:1.4.1
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/zuoxuchen/docker_test]
2653d992f4ef: Pushed
1.4.1: digest: sha256:f2b94498db210d953f8be571d395bb737988c69aa5683f959d437a5a9573f158 size: 529
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zuoxuchen_centos 1.4 57c8e3e58d02 7 minutes ago 209MB
registry.cn-hangzhou.aliyuncs.com/zuoxuchen/docker_test 1.4.1 57c8e3e58d02 7 minutes ago 209MB
centos latest 300e315adb2f 4 months ago 209MB