本篇内容主要讲解“Docker私有镜像仓库Harbor的搭建方式”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Docker私有镜像仓库Harbor的搭建方式”吧!
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-compose sudo 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 40524192 docker-py version: 4.3.1 CPython version: 3.7.7 OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
解压harbor软件包:
tar -zxvf harbor-offline-installer-v2.1.2.tgz
修改配置文件:
# cd harbor/ # ll total 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 # ls common.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.2 Loaded image: goharbor/prepare:v2.1.2 Loaded image: goharbor/harbor-log:v2.1.2 Loaded image: goharbor/harbor-registryctl:v2.1.2 Loaded image: goharbor/clair-adapter-photon:v2.1.2 Loaded image: goharbor/harbor-db:v2.1.2 Loaded image: goharbor/harbor-jobservice:v2.1.2 Loaded image: goharbor/clair-photon:v2.1.2 Loaded image: goharbor/notary-signer-photon:v2.1.2 Loaded image: goharbor/harbor-portal:v2.1.2 Loaded image: goharbor/redis-photon:v2.1.2 Loaded image: goharbor/nginx-photon:v2.1.2 Loaded image: goharbor/trivy-adapter-photon:v2.1.2 Loaded image: goharbor/harbor-core:v2.1.2 Loaded image: goharbor/registry-photon:v2.1.2 Loaded 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/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/portal/nginx.conf 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/registryctl/config.yml 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: /data/secret/keys/secretkey Successfully called func: create_root_cert Generated configuration file: /compose_location/docker-compose.yml Clean up the input dir [Step 5]: starting Harbor ... Creating network "harbor_harbor" with the default driver Creating harbor-log ... done Creating registry ... done Creating harbor-db ... done Creating redis ... done Creating registryctl ... done Creating harbor-portal ... done Creating harbor-core ... done Creating harbor-jobservice ... done Creating nginx ... done ✔ ----Harbor has been installed and started successfully.---- [root@resources harbor]#
⚠:安装完后,安装目录下会变成这样,如下图:
可以看到其中多出一个docker-compose.yml文件,这也是基于harbor.yml生成的供docker-compose调用创建容器的服务编排文件。
安装完成后,通过配置中设置的IP或域名+端口,即可访问Harbor管理控制台,如果端口占用,可以去安装目录下harbor.yml文件中,对应服务的端口映射。
测试安装是否成功,使用安装时在harbor.yml中设置的管理员密码,用户名是admin,登录控制台:
登录成功,进入首页,如下图:
至此Harbor 搭建成功!!
到此,相信大家对“Docker私有镜像仓库Harbor的搭建方式”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。