共计 2270 个字符,预计需要花费 6 分钟才能阅读完成。
本文记录公布镜像到
DockerHub
和阿里云镜像仓库
。工作中应用的是JFrog Artifactory
和Harbor
,没有太大差异。
公布镜像到 DockerHub
https://hub.docker.com/ 注册账号
1、登录 docker
[[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] ~]#
[[email protected] ~]# docker login -u xiaobluewhale
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] ~]#
2、服务器上提交镜像
docker push [OPTIONS] NAME[:TAG]
docker push
命令推送镜像的标准是:注册用户名 / 镜像名。
应用以下办法之一命名您的本地镜像:
- 当你构建它们时,应用如下命令
docker build -t <hub-user>/<repo-name>[:<tag>]
- 重命名现有的本地镜像
docker tag <existing-image> <hub-user>/<repo-name>[:<tag>]
docker commit
提交更改
docker commit <existing-container> <hub-user>/<repo-name>[:<tag>]
- 推送镜像仓库
docker push <hub-user>/<repo-name>:<tag>
docker push xiao/tomcat
docker push xiao/tomcat
Using default tag: latest
The push refers to repository [docker.io/xiao/tomcat]
69421fc728fb: Preparing
1f6217f0c2bb: Preparing
aa9c3f9fafec: Preparing
7d4a4cd414a9: Preparing
74ddd0ec08fa: Preparing
denied: requested access to the resource is denied
推送失败,被回绝
推送失败的起因: name 必须是注册用户名
解决 push 失败问题
减少一个 tag, 重命名镜像
# 减少 tag,重命名镜像
docker tag 24b3a476f143 xiaobluewhale/tomcat:1.0
The push refers to repository [docker.io/xiaobluewhale/tomcat]
# 查看镜像
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xiaobluewhale/tomcat 1.0 24b3a476f143 13 hours ago 680MB
xiao/tomcat 1.0 24b3a476f143 13 hours ago 680MB
xiao/tomcat latest 24b3a476f143 13 hours ago 680MB
# 推送镜像
docker push xiaobluewhale/tomcat:1.0
提交胜利
提交的时候也是依照镜像的层级提交的
在集体 DockerHub 上查看推送胜利的镜像
公布镜像到阿里云镜像仓库
1、登陆阿里云
2、找到容器镜像服务,创立实例
企业版须要付费购买(1 个月 741)
我抉择创立 集体实例
3、创立命名空间(为了隔离)
4、创立镜像仓库
本地
5、推送镜像
参考阿里云容器镜像指南
- 登录
docker login --username=[yourname] registry.cn-hangzhou.aliyuncs.com
- 查看镜像
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xiaobluewhale/tomcat 1.0 24b3a476f143 14 hours ago 680MB
- 推送镜像
docker push xiaobluewhale/tomcat:1.0
The push refers to repository [docker.io/xiaobluewhale/tomcat]
6、阿里云查看镜像
imageID: 24b3a476f143
也能够查看可视化的层信息
我是 甜点 cc
酷爱前端,也喜爱专研各种跟本职工作关系不大的技术,技术、产品趣味宽泛且浓重,期待着一个守业机会。本号次要致力于分享集体经验总结,心愿能够给一小部分人一些渺小帮忙。
心愿能和大家一起致力营造一个良好的学习气氛,为了集体和家庭、为了我国的互联网物联网技术、数字化转型、数字经济倒退做一点点奉献。数风流人物还看中国、看今朝、看你我。
正文完