天天看點

Docker-鏡像釋出到Dockerhub和阿裡雲一、釋出鏡像到DcokerHub二、釋出鏡像到阿裡雲鏡像倉庫三、Docker推送流程圖

一、釋出鏡像到DcokerHub

  1. 首先需要去https://hub.docker.com/網站注冊屬于自己的賬号;
  2. 确定新注冊的賬号可以登陸;
  3. 在我們的伺服器上送出自己制作的鏡像檔案。
[[email protected] ~]# 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

[[email protected] ~]# 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

[[email protected] ~]# 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标簽
[[email protected] ~]# docker  images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
tomcat01              latest              66fd9bfabe82        13 hours ago        695MB

[[email protected] ~]# 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

這裡需要對鏡像打一個标簽
[[email protected] ~]# docker tag 66fd9bfabe82 jzyue/tomcat01:1.0
[[email protected] ~]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
jzyue/tomcat01        1.0                 66fd9bfabe82        13 hours ago        695MB

           

二、釋出鏡像到阿裡雲鏡像倉庫

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

2.找到容器鏡像服務;

3.建立命名空間;

Docker-鏡像釋出到Dockerhub和阿裡雲一、釋出鏡像到DcokerHub二、釋出鏡像到阿裡雲鏡像倉庫三、Docker推送流程圖

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

Docker-鏡像釋出到Dockerhub和阿裡雲一、釋出鏡像到DcokerHub二、釋出鏡像到阿裡雲鏡像倉庫三、Docker推送流程圖
Docker-鏡像釋出到Dockerhub和阿裡雲一、釋出鏡像到DcokerHub二、釋出鏡像到阿裡雲鏡像倉庫三、Docker推送流程圖

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

Docker-鏡像釋出到Dockerhub和阿裡雲一、釋出鏡像到DcokerHub二、釋出鏡像到阿裡雲鏡像倉庫三、Docker推送流程圖
[[email protected] ~]# sudo docker login [email protected] 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
[[email protected] ~]# docker images  #檢視鏡像
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
jzyue/tomcat01        1.0                 66fd9bfabe82        14 hours ago        695MB
[[email protected] ~]# 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推送流程圖

Docker-鏡像釋出到Dockerhub和阿裡雲一、釋出鏡像到DcokerHub二、釋出鏡像到阿裡雲鏡像倉庫三、Docker推送流程圖
Docker-鏡像釋出到Dockerhub和阿裡雲一、釋出鏡像到DcokerHub二、釋出鏡像到阿裡雲鏡像倉庫三、Docker推送流程圖