docker倉庫之harbor的基本使用(二)

 1 1.配置docker使用harbor倉庫上傳下載鏡像
 2 #注意:若是咱們配置的是https的話,本地docker就不須要任何操做就能夠訪問harbor
 3 測試機器
 4 root@ubuntu1804:~# vim /lib/systemd/system/docker.service 
 5 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry 10.0.0.110
 6 
 7 2.重啓docker服務
 8 root@ubuntu1804:~# systemctl daemon-reload && systemctl restart docker
 9 
10 3.驗證可否登陸到harbor
11 
12 root@ubuntu1804:~# docker login 10.0.0.110
13 Username: admin
14 Password: 
15 WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
16 Configure a credential helper to remove this warning. See
17 https://docs.docker.com/engine/reference/commandline/login/#credentials-store
18 
19 Login Succeeded
20 
21 4.測試上傳和下載
22 
23 修改images的名稱,不修改爲指定格式沒法將鏡像上傳到harbor倉庫。
24 格式爲 harborIP/項目名/image 名字:版本號:
25 
26 root@ubuntu1804:~# docker tag nginx:latest 10.0.0.110/linux/nginx:latest      #我這邊的倉庫的項目名是linux。
27 
28 鏡像的上傳:
29 #上傳
30 root@ubuntu1804:~# docker push 10.0.0.110/linux/nginx
31 Using default tag: latest
32 The push refers to repository [10.0.0.110/linux/nginx]
33 85fcec7ef3ef: Pushed 
34 3e5288f7a70f: Pushed 
35 56bc37de0858: Pushed 
36 1c91bf69a08b: Pushed 
37 cb42413394c4: Pushed 
38 latest: digest: sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8 size: 1362
39 
40 
41 鏡像的下載
42 
43 
44 #下載
45 #這個機器是另一個機器用於測試拉取
46 #目前凡是須要從harbor鏡像服務器下載image的docker服務都要更改,不更改沒法下載
47 
48 #vim /lib/systemd/system/docker.service
49 
50 
51 root@ubuntu1804:/lib/systemd/system# docker pull 10.0.0.110/linux/nginx:latest
52 latest: Pulling from linux/nginx
53 a076a628af6f: Pull complete 
54 0732ab25fa22: Pull complete 
55 d7f36f6fe38f: Pull complete 
56 f72584a26f32: Pull complete 
57 7125e4df9063: Pull complete 
58 Digest: sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8
59 Status: Downloaded newer image for 10.0.0.110/linux/nginx:latest
60 10.0.0.110/linux/nginx:latest
61 root@ubuntu1804:/lib/systemd/system# docker images
62 REPOSITORY                      TAG             IMAGE ID       CREATED         SIZE
63 10.0.0.110/linux/nginx          latest          f6d0b4767a6c   3 weeks ago     133MB
64 
65 5.harbor界面驗證是否上傳

相關文章
相關標籤/搜索