Loading

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界面验证是否上传

 

posted @ 2021-02-25 20:57  梨花海棠  阅读(192)  评论(0编辑  收藏  举报