Docker-映象釋出到Dockerhub和阿里雲

jzyue2020發表於2020-12-16

一、釋出映象到DcokerHub

  1. 首先需要去https://hub.docker.com/網站註冊屬於自己的賬號;
  2. 確定新註冊的賬號可以登陸;
  3. 在我們的伺服器上提交自己製作的映象檔案。
[root@docker ~]# docker login --help

Usage:  docker login [OPTIONS] [SERVER]

Log in to a Docker registry.
If no server is specified, the default is defined by the daemon.

Options:
  -p, --password string   Password
      --password-stdin    Take the password from stdin
  -u, --username string   Username

[root@docker ~]# docker login -u jzyue  
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@docker ~]# docker push jzyue/tomcat01:1.0  #提交自己的映象到dockerhub上
The push refers to repository [docker.io/jzyue/tomcat01]
cd2c8c332d4e: Pushing [==============>                                    ]  6.523MB/23.23MB
097d8efb1a01: Pushing [==============>                                    ]  16.76MB/57.77MB
fc617a256ca8: Pushing [======================================>            ]  11.35MB/14.64MB
4de30c3ac6c2: Pushing [>                                                  ]  4.925MB/384.5MB
1fe7c48fedc6: Pushing [==================================================>]  3.072kB
291f6e44771a: Waiting

常見報錯

在提交的時候提示沒有tag標籤
[root@docker ~]# docker  images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
tomcat01              latest              66fd9bfabe82        13 hours ago        695MB

[root@docker ~]# docker push jzyue/diytomcat:1.0
The push refers to repository [docker.io/jzyue/diytomcat]
An image does not exist locally with the tag: jzyue/diytomcat

這裡需要對映象打一個標籤
[root@docker ~]# docker tag 66fd9bfabe82 jzyue/tomcat01:1.0
[root@docker ~]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
jzyue/tomcat01        1.0                 66fd9bfabe82        13 hours ago        695MB

二、釋出映象到阿里雲映象倉庫

1.登陸到阿里雲(https://account.aliyun.com);

2.找到容器映象服務;

3.建立名稱空間;

4.建立容器映象倉庫,倉庫型別:公開代表所有人都可以看到;私有隻有自己可以看到;

5.進入到倉庫,根據阿里雲的操作指南來實際操作一下。

[root@docker ~]# sudo docker login --username=jzyue2012@sina.cn registry.cn-beijing.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@docker ~]# docker images  #檢視映象
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
jzyue/tomcat01        1.0                 66fd9bfabe82        14 hours ago        695MB
[root@docker ~]# docker push jzyue/tomcat01:1.0  #推送映象到阿里雲倉庫
The push refers to repository [docker.io/jzyue/tomcat01]
cd2c8c332d4e: Pushed
097d8efb1a01: Pushed
fc617a256ca8: Pushed
4de30c3ac6c2: Pushing [============================================>      ]  340.6MB/384.5MB
1fe7c48fedc6: Layer already exists
291f6e44771a: Layer already exists

具體詳細操作參考阿里雲操作指南

三、Docker推送流程圖

相關文章