DockerHub
註冊dockerhub https://hub.docker.com/signup,需要有一個賬號
查看登錄命令
[root@xiaoyequ /]# 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 p
登錄
[root@xiaoyequ /]# docker login -u xiaoyequ666
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@xiaoyequ /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
diytomcat latest cfae60a041a3 12 hours ago 686MB
entrypointtest latest 81aedb452f1c 3 days ago 237MB
cmdtest latest ad2fb09d1b81 3 days ago 237MB
mycentos 0.1 0deef898a52e 4 days ago 321MB
xiaoyequ/centos latest 905fe8ff663c 5 days ago 237MB
tomcat02 1.0 57d6e3382b24 5 days ago 649MB
redis latest 235592615444 9 days ago 104MB
tomcat latest 2eb5a120304e 9 days ago 647MB
mysql 5.7 9cfcce23593a 10 days ago 448MB
nginx latest 4392e5dad77d 2 weeks ago 132MB
portainer/portainer latest cd645f5a4769 2 weeks ago 79.1MB
elasticsearch 7.6.2 f29a1ee41030 2 months ago 791MB
centos latest 470671670cac 5 months ago 237MB
[root@xiaoyequ /]# docker push xiaoyequ666/diytomcat:1.0
The push refers to repository [docker.io/xiaoyequ666/diytomcat]
An image does not exist locally with the tag: xiaoyequ666/diytomcat
問題:本地鏡像名無帳號信息,解決加 tag即可
docker tag cfae60a041a3 xiaoyequ666/tomcatofxiaoyequ:1.0
注意:斜槓前面的要和用戶名一致(xiaoyequ666)
再次 push, ok
阿里雲鏡像服務
登錄阿里雲,找到容器鏡像服務
https://cr.console.aliyun.com/
創建命名空間
創建鏡像倉庫
點擊進入這個鏡像倉庫,可以看到所有的信息
測試推送發佈
登錄阿里雲
sudo docker login --username=小葉曲666 registry.cn-zhangjiakou.aliyuncs.com
設置 tag
sudo docker tag [ImageId] registry.cn-zhangjiakou.aliyuncs.com/xiaoyequ/xiaoyequ:[鏡像版本號]
[root@xiaoyequ /]# sudo docker tag 235592615444 registry.cn-zhangjiakou.aliyuncs.com/xiaoyequ/xiaoyequ:v1.0
推送命令
sudo docker push registry.cn-zhangjiakou.aliyuncs.com/xiaoyequ/xiaoyequ:[鏡像版本號]