一、釋出鏡像到DcokerHub
- 首先需要去https://hub.docker.com/網站注冊屬于自己的賬号;
- 确定新注冊的賬号可以登陸;
- 在我們的伺服器上送出自己制作的鏡像檔案。
[[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.建立命名空間;
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAzNfRHLGZkRGZkRfJ3bs92YsYTMfVmepNHLzUleNd3ZU1kMRpHW3BjMMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnLwEjMxIjMyYDM2EjMxAjMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
4.建立容器鏡像倉庫,倉庫類型:公開代表所有人都可以看到;私有隻有自己可以看到;
5.進入到倉庫,根據阿裡雲的操作指南來實際操作一下。
[[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
具體詳細操作參考阿裡雲操作指南