最新版 Harbor 在ubuntu零碎上装置

The latest version of Harbor is installed on the ubuntu system

装置docker

Install docker

root@hello:~# curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyunroot@hello:~#

配置Docker Compose

Configure Docker Compose

root@hello:~# sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed100   633  100   633    0     0   2444      0 --:--:-- --:--:-- --:--:--  2444100 12.1M  100 12.1M    0     0  10.2M      0  0:00:01  0:00:01 --:--:-- 26.2Mroot@hello:~#  sudo chmod +x /usr/local/bin/docker-composeroot@hello:~# sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-composeroot@hello:~# docker-compose --versiondocker-compose version 1.29.2, build 5becea4croot@hello:~#

下载Docker Harbor安装包

Download the Docker Harbor installation package

root@hello:~# wget https://github.com/goharbor/harbor/releases/download/v2.3.2/harbor-offline-installer-v2.3.2.tgzroot@hello:~#

解压安装包

Unzip the installation package

root@hello:~# tar xvf harbor-offline-installer-v2.3.2.tgz  -C /usr/local/ harbor/harbor.v2.3.2.tar.gzharbor/prepareharbor/LICENSEharbor/install.shharbor/common.shharbor/harbor.yml.tmplroot@hello:~# cd /usr/local/harbor/

配置证书

Configure Certificate

root@hello:/usr/local/harbor# mkdir caroot@hello:/usr/local/harbor# cd ca/root@hello:/usr/local/harbor/ca# pwd/usr/local/harbor/caroot@hello:/usr/local/harbor/ca# openssl genrsa -des3 -out server.key 2048Generating RSA private key, 2048 bit long modulus (2 primes)......................................+++++...................................................................................................................................................+++++e is 65537 (0x010001)Enter pass phrase for server.key:Verifying - Enter pass phrase for server.key:root@hello:/usr/local/harbor/ca# root@hello:/usr/local/harbor/ca# root@hello:/usr/local/harbor/ca# openssl req -new -key server.key -out server.csrEnter pass phrase for server.key:You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [AU]:State or Province Name (full name) [Some-State]:Locality Name (eg, city) []:Organization Name (eg, company) [Internet Widgits Pty Ltd]:Organizational Unit Name (eg, section) []:Common Name (e.g. server FQDN or YOUR name) []:Email Address []:Please enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:An optional company name []:root@hello:/usr/local/harbor/ca# root@hello:/usr/local/harbor/ca# cp server.key server.key.orgroot@hello:/usr/local/harbor/ca# openssl rsa -in server.key.org -out server.keyEnter pass phrase for server.key.org:writing RSA keyroot@hello:/usr/local/harbor/ca# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crtSignature oksubject=C = AU, ST = Some-State, O = Internet Widgits Pty LtdGetting Private keyroot@hello:/usr/local/harbor/ca#

批改配置文件,批改 hostname 和证书门路 即可

Modify the configuration file, modify the hostname and certification path

root@hello:/usr/local/harbor# cp harbor.yml.tmpl harbor.ymlroot@hello:/usr/local/harbor# root@hello:/usr/local/harbor# vim harbor.ymlroot@hello:/usr/local/harbor# cat harbor.yml# Configuration file of Harborhostname: harbor.chenby.cn# http related confighttp:  # port for http, default is 80. If https enabled, this port will redirect to https port  port: 80# https related confighttps:  # https port for harbor, default is 443  port: 443  # The path of cert and key files for nginx  certificate: /usr/local/harbor/ca/server.crt  private_key: /usr/local/harbor/ca/server.keyharbor_admin_password: Harbor12345----略----root@hello:/usr/local/harbor#

装置

Install

root@hello:/usr/local/harbor# ./install.sh[Step 0]: checking if docker is installed ...Note: docker version: 20.10.8[Step 1]: checking docker-compose is installed ...Note: docker-compose version: 1.29.2[Step 2]: loading Harbor images ...Loaded image: goharbor/redis-photon:v2.3.2Loaded image: goharbor/nginx-photon:v2.3.2Loaded image: goharbor/harbor-portal:v2.3.2Loaded image: goharbor/trivy-adapter-photon:v2.3.2Loaded image: goharbor/chartmuseum-photon:v2.3.2Loaded image: goharbor/notary-signer-photon:v2.3.2Loaded image: goharbor/harbor-core:v2.3.2Loaded image: goharbor/harbor-log:v2.3.2Loaded image: goharbor/harbor-registryctl:v2.3.2Loaded image: goharbor/harbor-exporter:v2.3.2Loaded image: goharbor/notary-server-photon:v2.3.2Loaded image: goharbor/prepare:v2.3.2Loaded image: goharbor/harbor-db:v2.3.2Loaded image: goharbor/harbor-jobservice:v2.3.2Loaded image: goharbor/registry-photon:v2.3.2[Step 3]: preparing environment ...[Step 4]: preparing harbor configs ...prepare base dir is set to /usr/local/harborClearing the configuration file: /config/portal/nginx.confClearing the configuration file: /config/log/rsyslog_docker.confClearing the configuration file: /config/log/logrotate.confGenerated configuration file: /config/portal/nginx.confGenerated configuration file: /config/log/logrotate.confGenerated configuration file: /config/log/rsyslog_docker.confGenerated configuration file: /config/nginx/nginx.confGenerated configuration file: /config/core/envGenerated configuration file: /config/core/app.confGenerated configuration file: /config/registry/config.ymlGenerated configuration file: /config/registryctl/envGenerated configuration file: /config/registryctl/config.ymlGenerated configuration file: /config/db/envGenerated configuration file: /config/jobservice/envGenerated configuration file: /config/jobservice/config.ymlGenerated and saved secret to file: /data/secret/keys/secretkeySuccessfully called func: create_root_certGenerated configuration file: /compose_location/docker-compose.ymlClean up the input dir[Step 5]: starting Harbor ...Creating network "harbor_harbor" with the default driverCreating harbor-log ... doneCreating harbor-portal ... doneCreating harbor-db     ... doneCreating registryctl   ... doneCreating redis         ... doneCreating registry      ... doneCreating harbor-core   ... doneCreating harbor-jobservice ... doneCreating nginx             ... done? ----Harbor has been installed and started successfully.----root@hello:/usr/local/harbor#

配置dns解析,或者在本地host中配置,具体配置略

Configure dns resolution, or configure in the local host, the specific configuration is omitted

登陆

Sign in

默认账号:admin

默认明码:Harbor12345

Default account: admin

Default password: Harbor12345

客户端应用

Client use

root@hello:~# vim /etc/docker/daemon.jsonroot@hello:~# root@hello:~# cat /etc/docker/daemon.json{  "insecure-registries": ["https://harbor.chenby.cn"]}root@hello:~# root@hello:~# systemctl daemon-reloadroot@hello:~# root@hello:~# root@hello:~# sudo systemctl restart dockerroot@hello:~# docker login https://harbor.chenby.cn/Username: adminPassword: WARNING! Your password will be stored unencrypted in /root/.docker/config.json.Configure a credential helper to remove this warning. Seehttps://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeededroot@hello:~#

Linux运维交换社区

Linux运维交换社区,互联网新闻以及技术交换。

38篇原创内容

公众号

本文应用 文章同步助手 同步