0
点赞
收藏
分享

微信扫一扫

Docker镜像从Harbor仓库的上传和拉取

公司使用的是Harbor(开源的企业容器镜像仓库),下面演示docker镜像提交和拉取过程

1.  登录镜像仓库Harbor:

已有Harbor的登录账号,可管理镜像,先创建一个项目“文件夹test”,可设置成公开或者不公开,不公开在别人拉取镜像时需要输入用户密码。

2. 在Harbor中创建新项目目录:

Docker推送命令:

在项目中标记镜像:

docker tag SOURCE_IMAGE[:TAG] reg.xxx.cn/test/REPOSITORY[:TAG]

推送镜像到当前项目:

docker push reg.xxx.cn/test/REPOSITORY[:TAG]

Docker镜像从Harbor仓库的上传和拉取_docker



3. 上传镜像到镜像仓库:

下面需要我们把服务器上打包的镜像发布到Harbor上,镜像为http://blog.chinaunix.net/uid-30199261-id-5855636.html中我build的

【build镜像:docker build -t df_interface_test .

docker images查询可看到新建镜像证明build成功了:

df_interface_test                                           latest              132d4004e491        43 seconds ago      1.04GB

*发布之前需要先登录到镜像仓库:docker login -u  -p  reg.xxx.cn,否则无权限上传

*打tag:docker tag df_interface_test:latest reg.xxx.cn/test/df_interface_test:v1

*push镜像:docker push reg.xxx.cn/test/df_interface_test:v1

(如果公用的服务器在传完可选择退出镜像仓库:docker logout reg.xxx.cn)

检查是否上传成功了,进入Harbor看在test文件夹下是否有上传的新镜像


4. 拉取镜像到测试服务器:

从Harbor中如下图中查看拉取命令:

Docker镜像从Harbor仓库的上传和拉取_上传_02

用上图中的拉取命令拉取镜像,得到的镜像docker images查看没有版本信息none,下面的拉取命令
可带tag信息:

docker pull reg.xxx.cn/test/df_interface_test:v1

查看是否拉取成功,docker images|grep df_interface_test

reg.xxx.cn/test/df_interface_test    v1    570d00343213   7 months ago    1.04GB


5.至此镜像拉取成功,后面可进行docker容器的运行了。


===========================

补充镜像拉取的权限问题:

设置为私有的镜像,外人直接拉取不了,得让镜像管理人给你开通权限:项目-配置管理-仓库公开(此公开是针对有证书的公开,并非对外完全公开),否则

执行docker pull reg.xxx.cn/sec/xxx_interface_test:v1报错:

Error response from daemon: unauthorized: unauthorized to access repository: sec/xxx_interface_test, action: pull: unauthorized to access repository: sec/xxx_interface_test, action: pull

举报

相关推荐

0 条评论