docker学习(十四)离线安装harbor

一、安装harbor

1、下载

下载地址: https://github.com/goharbor/harbor/releases

在这里插入图片描述
2、环境准备

(1)安装docker

[root@swarm-master nginx]# docker --version
Docker version 18.06.3-ce, build d7080c1

(2)安装docker-compose

[root@swarm-master nginx]# docker-compose --version
docker-compose version 1.27.3, build 4092ae5d

3、安装harbor

将下载的离线包 harbor-offline-installer-v2.3.4.tgz 上传到服务器某一目录,例如 /opt/software/harbor

(1)解压

tar -zxvf harbor-offline-installer-v2.3.4.tgz

进入解压目录

[root@swarm-master harbor]# cd harbor
[root@swarm-master harbor]# ll
؜ԃ 596284
-rw-r--r--. 1 root root      3361 11Ղ  9 06:01 common.sh
-rw-r--r--. 1 root root 610560420 11Ղ  9 06:01 harbor.v2.3.4.tar.gz
-rw-r--r--. 1 root root      7840 11Ղ  9 06:01 harbor.yml.tmpl
-rwxr-xr-x. 1 root root      2500 11Ղ  9 06:01 install.sh
-rw-r--r--. 1 root root     11347 11Ղ  9 06:01 LICENSE
-rwxr-xr-x. 1 root root      1881 11Ղ  9 06:01 prepare

(2)重命名 harbor.yml.tmpl 为 harbor.yml

cp harbor.yml.tmpl harbor.yml

编辑该文件,将https相关注释掉

在这里插入图片描述
(3)加载镜像

docker load -i harbor.v2.3.4.tar.gz

查看镜像

[root@swarm-master harbor]# docker images | grep goharbor
goharbor/harbor-exporter        v2.3.4              41f7fb260d0d        4 weeks ago         81.1MB
goharbor/chartmuseum-photon     v2.3.4              f460981da720        4 weeks ago         179MB
goharbor/redis-photon           v2.3.4              e4780c57b230        4 weeks ago         155MB
goharbor/trivy-adapter-photon   v2.3.4              af0652363af0        4 weeks ago         130MB
goharbor/notary-server-photon   v2.3.4              66c118fdbe3e        4 weeks ago         110MB
goharbor/notary-signer-photon   v2.3.4              27d49a4ae0d3        4 weeks ago         108MB
goharbor/harbor-registryctl     v2.3.4              0daeaba57fc6        4 weeks ago         133MB
goharbor/registry-photon        v2.3.4              8497f259228a        4 weeks ago         81.9MB
goharbor/nginx-photon           v2.3.4              2218fcda1ff0        4 weeks ago         45MB
goharbor/harbor-log             v2.3.4              4d507b2e8131        4 weeks ago         159MB
goharbor/harbor-jobservice      v2.3.4              5924b12f0b85        4 weeks ago         211MB
goharbor/harbor-core            v2.3.4              dc8b74f8c4f3        4 weeks ago         193MB
goharbor/harbor-portal          v2.3.4              770e6950323b        4 weeks ago         58.2MB
goharbor/harbor-db              v2.3.4              8e2ed50e4699        4 weeks ago         228MB
goharbor/prepare                v2.3.4              cce1a590410d        4 weeks ago         254MB

(4)安装

./prepare
./install.sh

...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating registry      ... done
Creating redis         ... done
Creating registryctl   ... done
Creating harbor-portal ... done
Creating harbor-db     ... done
Creating harbor-core   ... done
Creating harbor-jobservice ... done
Creating nginx             ... done
✔ ----Harbor has been installed and started successfully.----

(5)查看容器

[root@swarm-master harbor]# docker-compose ps
      Name                     Command                  State                 Ports          
---------------------------------------------------------------------------------------------
harbor-core         /harbor/entrypoint.sh            Up (healthy)                            
harbor-db           /docker-entrypoint.sh 96 13      Up (healthy)                            
harbor-jobservice   /harbor/entrypoint.sh            Up (healthy)                            
harbor-log          /bin/sh -c /usr/local/bin/ ...   Up (healthy)   127.0.0.1:1514->10514/tcp
harbor-portal       nginx -g daemon off;             Up (healthy)                            
nginx               nginx -g daemon off;             Up (healthy)   0.0.0.0:80->8080/tcp     
redis               redis-server /etc/redis.conf     Up (healthy)                            
registry            /home/harbor/entrypoint.sh       Up (healthy)                            
registryctl         /home/harbor/start.sh            Up (healthy)  

示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。

二、测试

1、浏览器访问 http://172.16.10.151/

输入默认用户名密码 admin/Harbor12345

在这里插入图片描述
2、测试镜像

(1)在另一台机器172.16.10.153上配置harbor地址

vi /etc/docker/daemon.json

[root@swarm-node02 ~]# cat /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver= cgroupfs"],
  "insecure-registries":["172.16.10.151:80"]
}

(2)重启docker

systemctl daemon-reload 
systemctl restart docker

(3)登录harbor

[root@swarm-node02 ~]# docker login -u admin -p Harbor12345 172.16.10.151:80
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

(4)推送镜像

使用nginx镜像打tag

docker tag  nginx:latest 172.16.10.151:80/library/nginx:latest

推送镜像

[root@swarm-node02 ~]# docker push 172.16.10.151:80/library/nginx:latest
The push refers to repository [172.16.10.151:80/library/nginx]
2bed47a66c07: Pushed 
82caad489ad7: Pushed 
d3e1dca44e82: Pushed 
c9fcd9c6ced8: Pushed 
0664b7821b60: Pushed 
9321ff862abb: Pushed 
latest: digest: sha256:4424e31f2c366108433ecca7890ad527b243361577180dfd9a5bb36e828abf47 size: 1570

(5)下载镜像

删除本地镜像

docker rmi 172.16.10.151:80/library/nginx:latest

下载镜像

[root@swarm-node02 ~]# docker pull 172.16.10.151:80/library/nginx:latest
latest: Pulling from library/nginx
Digest: sha256:4424e31f2c366108433ecca7890ad527b243361577180dfd9a5bb36e828abf47
Status: Downloaded newer image for 172.16.10.151:80/library/nginx:latest
172.16.10.151:80/library/nginx:latest

(6)浏览器查看

镜像已经推送到harbor仓库中
在这里插入图片描述

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_lrs

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值