将本地镜像上传到Harbor仓库以及下载
上传镜像
给镜像打上标签
[root@dj-virtual-machine /]# docker tag eureka7001:v1 192.168.8.150:88/tensquare/eureka7001:v1
推送镜像
[root@dj-virtual-machine /]# docker push 192.168.8.150:88/tensqure/eureka7001:v1
The push refers to repository [192.168.8.150:88/tensqure/eureka7001]
Get https://192.168.8.150:88/v2/: http: server gave HTTP response to HTTPS client
# 以上报错,是因为Docker未将Harbor加入到信任列表中
# 将Harbor地址加入Docker信任列表,终端执行以下命令:
[root@dj-virtual-machine /]# vim /etc/docker/daemon.json
# 可能 daemon.json 文件并不存在,需要自行手动创建。
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com",
"https://hub-mirror.c.163.com",
"https://mirror.ccs.tencentyun.com",
"http://f1361db2.m.daocloud.io"
],
+ "insecure-registries": [
+ "192.168.8.150:88"
+ ]
}
# 重启Docker
[root@dj-virtual-machine /]# systemctl daemon-reload
[root@dj-virtual-machine /]# systemctl restart docker
# 启动Harbor
[root@dj-virtual-machine /]# cd /home/dj/dev/harbor/harbor1.9.2/
[root@dj-virtual-machine harbor1.9.2]# ./install.sh
# 再次推送镜像
[root@dj-virtual-machine harbor1.9.2]# docker push 192.168.8.150:88/tensqure/eureka7001:v1
The push refers to repository [192.168.8.150:88/tensqure/eureka7001]
c0b9f3610428: Preparing
ceaf9e1ebef5: Preparing
9b9b7f3d56a0: Preparing
f1b5933fe4b5: Preparing
denied: requested access to the resource is denied
---------- ---------- ----------
# 新的问题,提示权限不足。(因为项目属于私有项目,需要提前登录)
[root@dj-virtual-machine ~]# docker login -u tom -p Tom123456 192.168.8.150:88
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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
# 再次Push就好了
[root@dj-virtual-machine harbor1.9.2]# docker push 192.168.8.150:88/tensquare/eureka7001:v1
The push refers to repository [192.168.8.150:88/tensquare/eureka7001]
c0b9f3610428: Pushed
ceaf9e1ebef5: Pushed
9b9b7f3d56a0: Pushed
f1b5933fe4b5: Pushed
v1: digest: sha256:49e8a4db750fe9deff8977c9ded56249d79dfbd292dc42140137e6e2aea04770 size: 1159
下载镜像
# 拉取镜像前仍需要提前登录
[root@dj-virtual-machine /]# docker login -u tom -p Tom123456 192.168.8.150:88
# 进行镜像拉取
[root@dj-virtual-machine /]# docker pull 192.168.8.150:88/tensquare/eureka7001:v1
v1: Pulling from tensquare/eureka7001
Digest: sha256:49e8a4db750fe9deff8977c9ded56249d79dfbd292dc42140137e6e2aea04770
Status: Image is up to date for 192.168.8.150:88/tensquare/eureka7001:v1
192.168.8.150:88/tensquare/eureka7001:v1
DJOSIMON