一、harbor推送镜像

1. 推送

  • 1.1 准备

先拉取一个镜像下来做试验用:

docker pull nginx

  • 1.2 标记镜像

给待推送的镜像打标记,打标记命令格式如下:

docker tag SOURCE_IMAGE[:TAG] ip:port/libName/REPOSITORY[:TAG]

SOURCE_IMAGE[:TAG]表示当前docker已存在的某个版本的镜像

library表示的是harbor里头的某个项目名称,表示镜像推送给这个项目

注意,其中ip和端口都不要省(尤其在http协议里头)

比如我要推送nginx到harbor仓库,打的标记如下:

docker tag nginx:latest harbor.111f6.cn/cuichao/nginx:latest
  • 1.3 登录docker

执行以下命令

docker login harbor.111f6.cn

登出docker的命令:

docker logout

登录成功

[root@VM-4-7-centos harbor]# docker login harbor.111f6.cn
Username: cuichao
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@VM-4-7-centos harbor]# 
  • 1.4 推送镜像

推送命令:

docker push harbor.111f6.cn/cuichao/nginx:latest

docker push后面的其实就是打标记的时候标记。

比如我要推送上面已经打好标记的镜像,命令如下:

docker push harbor.111f6.cn/cuichao/nginx:latest

推送日志

[root@VM-4-7-centos harbor]# docker push harbor.111f6.cn/cuichao/nginx:latest
The push refers to repository [harbor.111f6.cn/cuichao/nginx]
fd31601f0be4: Pushed 
93b4c8c4ac05: Pushed 
b7df9f234b50: Pushed 
ab75a0b61bd1: Pushed 
c1b1bf2f95dc: Pushed 
4d99aab1eed4: Pushed 
a483da8ab3e9: Pushed 
latest: digest: sha256:9a09179391eb34b797a024dd4d13c836f067be2dd2351fd6819f888ba5e04fdb size: 1778
[root@VM-4-7-centos harbor]# 
  • 1.5 查看

harborcangku-auhpgbww.jpg