Harbor1.10.2离线安装

文章目录

  • 环境
  • 下载离线安装包
  • 安装docker-compose
  • 安装harbor
  • 页面访问
  • 上传镜像
    • 登陆异常
  • 另一节点拉取
  • 参考

环境

软件 版本
centos 7.4-1708
docker 18.03.0-ce
harbor 1.10.2

docker环境需要提前安装好

docker安装过程:安装过程

下载离线安装包

https://github.com/goharbor/harbor/releases
Harbor1.10.2离线安装_第1张图片
下载完成后上传到Linux主机上

  • 也可以从这里下载

  • 离线安装harbor镜像仓库,资源共613m,太大,分3个小卷下载

  • 下载harbor-offline-installer-v1.10.2.zip.001

  • 下载harbor-offline-installer-v1.10.2.zip.002

  • 下载harbor-offline-installer-v1.10.2.zip.003

  • 放在同一个目录里,解压第一个卷即可

[root@manager harbor]# ll
total 628280
-rw-r--r--. 1 root root 643358224 Apr 23 11:21 harbor-offline-installer-v1.10.2.tgz
[root@manager harbor]# tar -xvf harbor-offline-installer-v1.10.2.tgz 
harbor/harbor.v1.10.2.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml
[root@manager harbor]# ll
total 628280
drwxr-xr-x. 2 root root       118 Apr 23 11:22 harbor
-rw-r--r--. 1 root root 643358224 Apr 23 11:21 harbor-offline-installer-v1.10.2.tgz
[root@manager harbor]# ll
total 631564
-rw-r--r--. 1 root root      3398 Apr  3 11:57 common.sh
-rw-r--r--. 1 root root 646685659 Apr  3 11:58 harbor.v1.10.2.tar.gz
-rw-r--r--. 1 root root      5882 Apr  3 11:57 harbor.yml
-rwxr-xr-x. 1 root root      2284 Apr  3 11:57 install.sh
-rw-r--r--. 1 root root     11347 Apr  3 11:57 LICENSE
-rwxr-xr-x. 1 root root      1749 Apr  3 11:57 prepare
[root@manager harbor]# pwd
/opt/harbor/harbor

安装docker-compose

sudo curl -L https://github.com/docker/compose/releases/download/1.23.0-rc3/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose

如果下载的慢也可以从这里下载

  • 下载docker-compose

进入下载目录,增加可执行权限

[root@manager bin]# cd /usr/bin/
[root@manager bin]# ll | grep docker
-rwxr-xr-x.   1 root root    33251768 Mar 22  2018 docker
-rw-r--r--.   1 root root    11737728 Apr 23 13:34 docker-compose
......
[root@manager bin]# chmod +x docker-compose
[root@manager bin]# ll | grep docker-compose
-rwxr-xr-x.   1 root root    11737728 Apr 23 13:34 docker-compose

安装harbor

修改配置文件

# Configuration file of Harbor

# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: manager.node  #修改主机名

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 8089  #修改一个不会被占用的

# https related config
# https:  #暂时注掉
  # https port for harbor, default is 443
  # port: 443 #暂时注掉
  # The path of cert and key files for nginx
  # certificate: /your/certificate/path  #暂时不开https注掉
  # private_key: /your/private/key/path  #暂时不开https注掉

# Uncomment external_url if you want to enable external proxy
# And when it enabled the hostname will no longer used
# external_url: https://reg.mydomain.com:8433

# The initial password of Harbor admin
# It only works in first time to install harbor
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password: Harbor12345  #修改密码,暂用默认

执行prepare脚本

[root@manager harbor]# ./prepare 
prepare base dir is set to /opt/harbor/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /secret/keys/secretkey
Generated certificate, key file: /secret/core/private_key.pem, cert file: /secret/registry/root.crt
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir

执行安装脚本

[root@manager harbor]# sh install.sh 

[Step 0]: checking if docker is installed ...

Note: docker version: 18.03.0

[Step 1]: checking docker-compose is installed ...

Note: docker-compose version: 1.23.0

[Step 2]: loading Harbor images ...
fe0efe3b32dc: Loading layer [==================================================>]  63.56MB/63.56MB
5504ea8a1c89: Loading layer [==================================================>]  58.39MB/58.39MB
......
[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /opt/harbor/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
......
[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating redis         ... done
Creating registry      ... done
Creating registryctl   ... done
Creating harbor-db     ... done
Creating harbor-portal ... done
Creating harbor-core   ... done
Creating nginx             ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----

页面访问

直接访问主机IP:8089访问,可在harbor.yml中修改端口号
Harbor1.10.2离线安装_第2张图片
使用admin/Harbor12345登陆,密码也是配置文件中设置。

上传镜像

安装完harbor之后的镜像,其中tomcat:8.0是安装harbor之前pull下来的。

[root@manager harbor]# docker image  ls
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
goharbor/chartmuseum-photon     v1.10.2             f7233c953dd9        2 weeks ago         127MB
goharbor/harbor-migrator        v1.10.2             42527a4df778        2 weeks ago         362MB
goharbor/redis-photon           v1.10.2             6d87eab10d9f        2 weeks ago         115MB
goharbor/clair-adapter-photon   v1.10.2             4e7edec88bf4        2 weeks ago         61.2MB
goharbor/clair-photon           v1.10.2             fb972d10c273        2 weeks ago         171MB
goharbor/notary-server-photon   v1.10.2             b6d909215dc4        2 weeks ago         143MB
goharbor/notary-signer-photon   v1.10.2             43c17fcb63de        2 weeks ago         140MB
goharbor/harbor-registryctl     v1.10.2             cff56bea907a        2 weeks ago         103MB
goharbor/registry-photon        v1.10.2             1c6cce6a4f8e        2 weeks ago         86.1MB
goharbor/nginx-photon           v1.10.2             c2de0026ba0d        2 weeks ago         43.6MB
goharbor/harbor-log             v1.10.2             c20325dbaa3a        2 weeks ago         81.9MB
goharbor/harbor-jobservice      v1.10.2             6283c53c8c32        2 weeks ago         143MB
goharbor/harbor-core            v1.10.2             4bc09e35734d        2 weeks ago         129MB
goharbor/harbor-portal          v1.10.2             bcb1b803a1bf        2 weeks ago         51.7MB
goharbor/harbor-db              v1.10.2             42de7ee4943f        2 weeks ago         152MB
goharbor/prepare                v1.10.2             3d2783911e0d        2 weeks ago         159MB
tomcat                          8.0                 ef6a7c98d192        19 months ago       356MB

运行着的容器

[root@manager harbor]# docker container ls -a
CONTAINER ID        IMAGE                                 COMMAND                  CREATED             STATUS                    PORTS                       NAMES
d9add84552ef        goharbor/nginx-photon:v1.10.2         "nginx -g 'daemon of…"   10 minutes ago      Up 10 minutes (healthy)   0.0.0.0:8089->8080/tcp        nginx
ac132aa7c3ea        goharbor/harbor-jobservice:v1.10.2    "/harbor/harbor_jobs…"   10 minutes ago      Up 10 minutes (healthy)                               harbor-jobservice
c8fc4fdd94cc        goharbor/harbor-core:v1.10.2          "/harbor/harbor_core"    10 minutes ago      Up 10 minutes (healthy)                               harbor-core
d95f52f80e02        goharbor/harbor-portal:v1.10.2        "nginx -g 'daemon of…"   10 minutes ago      Up 10 minutes (healthy)   8080/tcp                    harbor-portal
86123acd07f3        goharbor/harbor-db:v1.10.2            "/docker-entrypoint.…"   10 minutes ago      Up 10 minutes (healthy)   5432/tcp                    harbor-db
b8990a274125        goharbor/harbor-registryctl:v1.10.2   "/home/harbor/start.…"   10 minutes ago      Up 10 minutes (healthy)                               registryctl
862d3cf60dba        goharbor/registry-photon:v1.10.2      "/home/harbor/entryp…"   10 minutes ago      Up 10 minutes (healthy)   5000/tcp                    registry
890b077d63e9        goharbor/redis-photon:v1.10.2         "redis-server /etc/r…"   10 minutes ago      Up 10 minutes (healthy)   6379/tcp                    redis
2161a78e8d5c        goharbor/harbor-log:v1.10.2           "/bin/sh -c /usr/loc…"   10 minutes ago      Up 10 minutes (healthy)   127.0.0.1:1514->10514/tcp   harbor-log
cbbdd0e40330        tomcat:8.0                            "catalina.sh run"        3 hours ago         Up 3 hours                0.0.0.0:8889->8080/tcp      tomcat8

在harbor界面上创建一个新项目
Harbor1.10.2离线安装_第3张图片
创建一个新用户myuser1,密码Hb123456
Harbor1.10.2离线安装_第4张图片

登陆异常

[root@manager system]# docker login 10.180.249.57:8089
Username: myuser1
Password:    
Error response from daemon: Get https://10.180.249.57:8089/v2/: http: server gave HTTP response to HTTPS client

说的是docker client开启了https,服务端没开启
解决办法是修改/etc/docker/daemon.json文件

# vim /etc/docker/daemon.json
{
  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"],
  "insecure-registries": ["10.180.249.57:8089"] #增加这一行
}

重启docker

sudo systemctl daemon-reload
systemctl restart docker

再次登陆

[root@manager harbor]# docker login 10.180.249.57:8089
Username: myuser1
Password: 
Login Succeeded

tomcat:8.0重新打个tag

[root@manager harbor]# docker tag tomcat:8.0 10.180.249.57:8089/myproject/mytomcat:8.0

推到仓库里

[root@manager harbor]# docker push 10.180.249.57:8089/myproject/mytomcat:8.0
The push refers to repository [10.180.249.57:8089/myproject/mytomcat]
d0f3f4011f28: Pushed 
583dc95d65c9: Pushed 
f26731984f9b: Pushed 
9f052711b40a: Pushed 
81242e1e644e: Pushed 
39a6e47c4ae6: Pushed 
fc6174f0df4a: Pushed 
425325c72d90: Pushed 
c596d5191368: Pushed 
daf45b2cad9a: Pushed 
8c466bf4ca6f: Pushed 
8.0: digest: sha256:47274bc304687e21217ca6a33e3244c43c6d5cfaceade76c4b478023f2aca3b2 size: 2625

在myproject项目中镜像仓库里查看
Harbor1.10.2离线安装_第5张图片

另一节点拉取

[root@master ~]# docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
[root@master ~]# docker pull 10.180.249.57:8089/myproject/mytomcat
Using default tag: latest
Error response from daemon: Get https://10.180.249.57:8089/v2/: http: server gave HTTP response to HTTPS client

另一节点仍然需要修改daemon.json

[root@master ~]# vim /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"],
  "insecure-registries": ["10.180.249.57:8089"] #增加这一行
}
[root@master ~]# systemctl daemon-reload
[root@master ~]# systemctl restart  docker

再次拉取

[root@master ~]# docker pull 10.180.249.57:8089/myproject/mytomcat
Using default tag: latest
Error response from daemon: manifest for 10.180.249.57:8089/myproject/mytomcat:latest not found
[root@master ~]# docker pull 10.180.249.57:8089/myproject/mytomcat:8.0
8.0: Pulling from myproject/mytomcat
f189db1b88b3: Pull complete 
3d06cf2f1b5e: Pull complete 
edd0da9e3091: Pull complete 
eb7768aae14e: Pull complete 
e2780f585e0f: Pull complete 
e5ed720afeba: Pull complete 
d9e134700cfc: Pull complete 
e4804b33d02a: Pull complete 
b9df0c24315e: Pull complete 
49fdae8eaa20: Pull complete 
1aea3d9a32e6: Pull complete 
Digest: sha256:47274bc304687e21217ca6a33e3244c43c6d5cfaceade76c4b478023f2aca3b2
Status: Downloaded newer image for 10.180.249.57:8089/myproject/mytomcat:8.0
[root@master ~]# docker image ls
REPOSITORY                              TAG                 IMAGE ID            CREATED             SIZE
10.180.249.57:8089/myproject/mytomcat   8.0                 ef6a7c98d192        19 months ago       356MB

参考

https://blog.csdn.net/zyl290760647/article/details/83752877

你可能感兴趣的:(Docker)