Docker私有镜像仓库Harbor的搭建方式
本篇内容主要讲解"Docker私有镜像仓库Harbor的搭建方式",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"Docker私有镜像仓库Harbor的搭建方式"吧!
1、安装前准备
Harbor GitHub主页 https://github.com/goharbor/harbor
下载最新版本发布包,此处为 2.1.2 版本(大概500多M),如下图:
⚠ github 下载会很慢,可以用使用github加速工具进行下载加速!
安装docker,可查看 《CentOS安装Docker》
安装docker-compose, 可查看官网安装教程 https://docs.docker.com/compose/install
# linux 安装 docker-composesudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose# !如果下载慢或者无法下载【可以使用github加速工具或者方法】# 修改 docker-compose 权限sudo chmod +x /usr/local/bin/docker-compose# 建立系统软连接sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose# 验证是否成功docker-compose version# 输出如下,则安装成功docker-compose version 1.27.4, build 40524192docker-py version: 4.3.1CPython version: 3.7.7OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
2、安装Harbor
解压harbor软件包:
tar -zxvf harbor-offline-installer-v2.1.2.tgz
修改配置文件:
# cd harbor/# lltotal 533416-rw-r--r-- 1 root root 3361 Dec 9 17:19 common.sh-rw-r--r-- 1 root root 546180341 Dec 9 17:19 harbor.v2.1.2.tar.gz-rw-r--r-- 1 root root 8136 Dec 9 17:19 harbor.yml.tmpl-rwxr-xr-x 1 root root 2523 Dec 9 17:19 install.sh-rw-r--r-- 1 root root 11347 Dec 9 17:19 LICENSE-rwxr-xr-x 1 root root 1881 Dec 9 17:19 prepare##### 准备配置文件 ############## cp harbor.yml.tmpl harbor.yml# lscommon.sh harbor.v2.1.2.tar.gz harbor.yml harbor.yml.tmpl install.sh LICENSE prepare
然后修改 配置文件 harbor.yml,【新版本的配置文件已经由harbor.cfg改为harbor.yml】 修改4处,如下图:
hostname:可修改为IP或域名,此处修改为本机IP;
http.port:修改为非80端口即可,此处修改为9200;
harbor_admin_password:Harbor管理员密码,按需修改;
database.password:harbor 数据库密码,按需修改;
https: 注释掉这一块,默认开启 http, 除非你配置https证书;
执行安装命令
./install.sh
输出如下信息:
[root@resources harbor]# ./install.sh [Step 0]: checking if docker is installed ...Note: docker version: 20.10.1[Step 1]: checking docker-compose is installed ...Note: docker-compose version: 1.27.4[Step 2]: loading Harbor images ...Loaded image: goharbor/chartmuseum-photon:v2.1.2Loaded image: goharbor/prepare:v2.1.2Loaded image: goharbor/harbor-log:v2.1.2Loaded image: goharbor/harbor-registryctl:v2.1.2Loaded image: goharbor/clair-adapter-photon:v2.1.2Loaded image: goharbor/harbor-db:v2.1.2Loaded image: goharbor/harbor-jobservice:v2.1.2Loaded image: goharbor/clair-photon:v2.1.2Loaded image: goharbor/notary-signer-photon:v2.1.2Loaded image: goharbor/harbor-portal:v2.1.2Loaded image: goharbor/redis-photon:v2.1.2Loaded image: goharbor/nginx-photon:v2.1.2Loaded image: goharbor/trivy-adapter-photon:v2.1.2Loaded image: goharbor/harbor-core:v2.1.2Loaded image: goharbor/registry-photon:v2.1.2Loaded image: goharbor/notary-server-photon:v2.1.2[Step 3]: preparing environment ...[Step 4]: preparing harbor configs ...prepare base dir is set to /opt/soft/harborWARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to httpsGenerated 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 registry ... doneCreating harbor-db ... doneCreating redis ... doneCreating registryctl ... doneCreating harbor-portal ... doneCreating harbor-core ... doneCreating harbor-jobservice ... doneCreating nginx ... done✔ ----Harbor has been installed and started successfully.----[root@resources harbor]#
⚠:安装完后,安装目录下会变成这样,如下图:
可以看到其中多出一个docker-compose.yml文件,这也是基于harbor.yml生成的供docker-compose调用创建容器的服务编排文件。
3、登录Harbor
安装完成后,通过配置中设置的IP或域名+端口,即可访问Harbor管理控制台,如果端口占用,可以去安装目录下harbor.yml文件中,对应服务的端口映射。
测试安装是否成功,使用安装时在harbor.yml中设置的管理员密码,用户名是admin,登录控制台:
登录成功,进入首页,如下图:
至此Harbor 搭建成功!!
到此,相信大家对"Docker私有镜像仓库Harbor的搭建方式"有了更深的了解,不妨来实际操作一番吧!这里是网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!