1. 程式人生 > 其它 >將本地映象上傳到Harbor倉庫以及下載

將本地映象上傳到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