一、安装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:
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仓库中
|