背景介绍
Docker镜像构建成功后,只要有docker环境就可以使用,但必须将镜像推送到Docker Hub上去。创建的镜像最好要符合Docker Hub的tag要求,因为在Docker Hub注册的用户名是liboware,最后利用docker push命令推送镜像到公共仓库。
前提概要
你需要在Docker hub注册用户:到官网注册账号:https://hub.docker.com/
例如:注册账号名称:liboware
在本地服务器登录docker:
例如在CentOS7服务器
[root@localhost ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: liboware ##输入账号
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
nacos v1 9e5f6711d527 3 days ago 178MB
mysql v1 9e5f6711d527 3 days ago 178MB
docker tag建立镜像
[root@localhost ~]# docker tag nacos:v1 liboware/nacos:v1
docker images 查看镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nacos v1 9e5f6711d527 3 days ago 178MB
nginx v1 9e5f6711d527 3 days ago 178MB
liboware/mysql v1 9e5f6711d527 3 days ago 178MB
[root@localhost ~]#
docker hub推送镜像
docker push 注册docker用户名/REPOSITORY:TAG
[root@localhost ~]# docker push liboware/nacos:v1
The push refers to repository [docker.io/llxxyy/nginx-io]
833a0f6a6ff9: Pushed
10bfe402500e: Pushed
d43641d7d594: Mounted from library/nginx
c2adabaecedb: Mounted from library/nginx
v1: digest: sha256:67dcdae5578c0374019cc899731543cfd7c48fe5780e84233a258f2bf7d2ceda size: 1155
[root@localhost ~]#
注:推送Docker Hub速度很慢,耐心等待,很有可能失败,失败会尝试多次重传,之后断开推送(但已推送上去的会保留,保留时间不知道是多久)。
hub docker效果
Docker 使用发布的镜像
docker@default:~$ docker search liboware/nacos
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
liboware/nacos In this image server you can use ma... 0
在pull下来
[root@localhost ~]# docker pull liboware/nacos:v1
v1: Pulling from liboware/nacos
Digest: sha256:67dcdae5578c0374019cc899731543cfd7c48fe5780e84233a258f2bf7d2ceda
Status: Downloaded newer image for liboware/nacos:v1
docker.io/liboware/nacos:v2
确认pull成功
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx stable-perl 9e5f6711d527 3 days ago 178MB
nginx v1 9e5f6711d527 3 days ago 178MB
libo/nacos v1 9e5f6711d527 3 days ago 178MB
遇到的问题
-
执行:docker push nacos:v1【提示denied: requested access to the resource is denied】
-
我们可以列出所有镜像:docker images
-
建立tag将要发布的镜像改到自己账户名下,我的账户名:liboware
docker tag nacos:v2 liboware/nacos:v2
- 再次推送:docker push liboware/nacos:v2【成功】
本文来自博客园,作者:洛神灬殇,转载请注明原文链接:https://www.cnblogs.com/liboware/p/15712621.html,任何足够先进的科技,都与魔法无异。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/70102.html